sorttable.js - How to disable sorting on a column that has had sorting enabled on pageload?

682 Views Asked by At

Using sorttable.js - how can I disable sorting of a column or an entire after after sorting has been enabled on that table?

More information can be found here:

https://github.com/stuartlangridge/sorttable

http://www.kryogenix.org/code/browser/sorttable/

Any information on another table sorting plugin that works well with recent jquery releases would be appreciated as well.

1

There are 1 best solutions below

0
Shai UI On

here's a quick hack. do this after you loaded/sorted your table. assuming you have jquery. you might want to be more specific so it doesn't disable all your tables though.

$('th').css('pointer-events','none');


For example. go to that page you gave us.

http://www.kryogenix.org/code/browser/sorttable/ go to developer console in your web browser (right click and hit 'inspect') choose the console. copy & paste this, to inject jquery (since he hasn't loaded it on his webpage)

javascript:(function(){function l(u,i){
    var d=document;if(!d.getElementById(i)){var s=d.createElement('script');s.src=u;s.id=i;d.body.appendChild(s);}}l('http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js','jquery')})();

now type this statement.

$('th').css('pointer-events','none'); 

you'll see that his sorting doesn't work anymore.