Using Jquery Tablesorter, How To Make One Of The Columns The Default One That Sorts When The Page Loads?
I have a 3 column table (name, author, and date). When the page loads, it sorts the first column (name) by default. How can I make it sort the 3rd column (date) by default when t
Solution 1:
You can also pass in configuration options when you initialize the table using the sortList argument:
An array of instructions for per-column sorting and direction in the format: [[columnIndex, sortDirection], ... ] where columnIndex is a zero-based index for your columns left-to-right and sortDirection is 0 for Ascending and 1 for Descending. A valid argument that sorts ascending first by column 1 and then column 2 looks like: [[0,0],[1,0]]
Here's how to sort on the 3rd column
$(document).ready(function() {
// call the tablesorter plugin
$("table").tablesorter({
// sort on the third column, order ascsortList: [[2,0]]
}); });
Reference:
Post a Comment for "Using Jquery Tablesorter, How To Make One Of The Columns The Default One That Sorts When The Page Loads?"