Search code examples
jquerytablesorter

jQuery tablesorter disable last header


I am using tablesorter for my tables, and now I want that always the last header is disabled from sorting.

I have tried this:

 $(".sorter")
 .tablesorter({widgets: ['zebra'], headers:{0:{sorter:false}, -1:{sorter:false}}})          
 .tablesorterPager({container: $("#pager"), positionFixed: false, size : 5 });

But that does not work... does someone know a solution?


Solution

  • It is not a valid config to specify -1, try this

    var $sorterTable = $(".sorter");
    
    var tablesorterConfig = { widgets: ['zebra'], headers:{ 0:{sorter:false} } };
    
    tablesorterConfig.headers[$sorterTable.find("thead th").length - 1] = { sorter:false };
    
    
    $sorterTable
    .tablesorter(tablesorterConfig)          
    .tablesorterPager({container: $("#pager"), positionFixed: false, size : 5 });