Checkbox Parser and Bug Fix for jQuery TableSorter Plugin
I wanted to pass along a few things I have run into with the jquery tablesorter plugin that might help those of you who have been following my recent posts:
- Client Side ASP.NET ListView Sorting via jQuery TableSorter Plugin Demo
- Client Side Table Sorting, Paging and Filtering with jQuery Demo
I wanted to be able to sort by a column of checkboxes but the plugin doesn’t support it out of the box. Luckily the plugin is structured so that you can add your own parsers. I found a parser here to take care of sorting checkboxes. I think it was meant for an older version of the tablesorter plugin so I changed a few things to make it work with version 2.0.3. Just add the code below to the list of parsers in the plugin.
There is a bug when sorting numbers when the first item in the table is a “0”. The numbers are interpreted as text instead of digits and you will end up with a sequence like 1, 10, 2, 3, 31 etc. I found the solution in this jquery mailing list thread which uses a different regular expression in the isDigit function in the tablesorter.js plugin.
I hope these finds help you. Let me know if you find any other issues with the plugin or improve it in anyway.