I am using the jQuery Tablesorter 2.0 plugin to provide some basic table sorting functionality.
On my table, I would like to have a column for row number. The trouble is, the Tablesorter plugin sorts this column with everything else. I have tried setting the "headers" attribute for the first column, but that only removes sorting capability. It does not prevent the column from being reordered when I sort by a different column.
Is having a list of row numbers possible with this plugin? Can you think of a way around the problem?
It sounds like you need to renumber the rows every time the table is sorted. Try this (use it after you have already initialized tableSorter on your table):
var table = $("#myTable");
table.bind("sortEnd",function() {
var i = 1;
table.find("tr:gt(0)").each(function(){
$(this).find("td:eq(0)").text(i);
i++;
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With