I have a lot of table using tablesorter on my website and I'm looking for a way to sort "sorter: 'digit' a column that have a specific classname : "class="note".
I know of to do this with a header :
$(".tablesorter").tablesorter({
headers: {
0: { sorter: 'digit' } // column number, type
} });
But is there a generic way to do that is the html like this :
<th class="{sorter: 'digit'}">Note</th>
or with the classname <th class="note">Note</th>
somewhere in the javascript like this
$(".tablesorter .note").tablesorter() ...
?
Because my column "note" is sometime the third column, sometime the fifth etc.
I ask this because without the "digit" order specified, tablesorter does not know how to sort numbers ... Here is un jsfiddle to show what I mean : http://jsfiddle.net/2cmuy39L/
Thank you.
If you are using my fork of tablesorter, you can accomplish this at least two different ways:
Add a sorter-digit
class name to the headers
<th class="note sorter-digit">Note</th>
use a Class name in the headers
option (added in v2.17.0) - here is a demo:
headers : {
'.note' : { sorter: 'digit' }
}