I have a set of records in a list with initial number on the left column, like this:
No-Name-Age 1. Jack 50 2. Bill 35 3. Wayne 30 4. Mike 15 开发者_StackOverflow社区This is my code.
$("#datatable").tablesorter({
headers:{0: {sorter: false}},
widgets: ['zebra']
});
I can make the headers unclickable, but what I want is to make the initial number unsortable, so when user sorts by age, they would be like this:
1. Mike 15 2. Wayne 30 3. Bill 35 4. Jack 50How is it possible?
Thank you.Don't worry about making the first column unsortable, just rewrite the values every time the table is sorted:
$('table').tablesorter(/* Your favorite options */);
$('table').bind('sortend', function() {
$(this).find('tbody tr td:first-child').each(function(i) {
$(this).html((i + 1) + '.');
});
});
The index numbers in the first column aren't real data anywhere, they're generated so generating them every time not only solves your problem but makes sense too.
精彩评论