You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Basically, you can just set the sorter-false class in all desired header columns:
$('table thead th').addClass('sorter-false').filter(':eq(2), :eq(3)')// or select a range - the order of the filters is important!// .filter(':lt(10)').filter(':gt(3)') // allow sorting columns 4-9 (zero-based index).removeClass('sorter-false');
The way the plugin checks the column sorter is in this order of priority:
jQuery Data data-sorter="false" added to the th.
Metadata class="{ sorter: false }". This requires the metadata plugin.
So basically if a column has a class name of sorter-false and the headers options is { 0 : { sorter: 'digit' } }, the headers option wins.
There are other ways to disable column sorting. This method was also shown in that StackOverflow question because it would work with the original version of tablesorter:
varheaders={},$table=$('#myTable'),i,l=$table.find('thead th').length,// choose the columns you want to sort (zero-based index)sortcolumns=[2,3,4,5];// build headers object; based on sortcolumn selectionsfor(i=0;i<l;i++){if($.inArray(i,sortcolumns)<0){headers[i]={sorter: false}}}$table.tablesorter({widgets: ['zebra'],headers: headers// headers object built above});
Is there an easier way to do this than:
If there indeed is a way of doing this, it is not documented or hard to find in the documentation.
The text was updated successfully, but these errors were encountered: