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
I received a request to disable sorting when a minimum number of rows is not present. Also in that discussion was a request to allow hiding the thead with an empty table and modifying the table caption.
I think the best solution would be to use the initialized and updateComplete callback functions, but I won't be able to make a demo until later.
The text was updated successfully, but these errors were encountered:
Ok, I made this demo. And this is the core javascript coding needed:
varminRows=3,// Minimum number of rows needed before tablesorter allows sorting$t=$('table'),// check number of rows; enable or disable sortingcheckRows=function(){// check number of rowsvarmin=$t.find('tbody tr').length<minRows;// go through each header and enable/disable as needed$t[0].config.$headers.each(function(i){// only enable/disable certain columns (ignore 5th column, it's always disabled)if(i<4){// disable sort per columnthis.sortDisabled=min;// add sorter-false class to hide controls$(this).toggleClass('sorter-false',min);}});};$t// check number of rows after initialization & updates.on('tablesorter-initialized updateComplete',checkRows)// initialize tablesorter.tablesorter({theme: 'blue',widgets: ['zebra','columns']});
Update: To remove default tablesorter styling, include this change in the code (demo):
if(i<4){// disable sort per columnthis.sortDisabled=min;// remove table styling completely when not enabled$t.toggleClass('tablesorter-blue',!min);$(this).toggleClass('tablesorter-header',!min);// add sorter-false class to hide controls$(this).toggleClass('sorter-false',min);}
I received a request to disable sorting when a minimum number of rows is not present. Also in that discussion was a request to allow hiding the thead with an empty table and modifying the table caption.
I think the best solution would be to use the
initialized
andupdateComplete
callback functions, but I won't be able to make a demo until later.The text was updated successfully, but these errors were encountered: