Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

tablesorter update

I have a table which is updated with ajax and I need to pass headers as well as sorting using trigger update.

I am trying like below but its not working :

$(".tablesorter").trigger("update");

var header = "0: { sorter: false }, 1: { sorter: false }, 6: { sorter:'customDate'}, 7: {sorter:'customTime' }, 8: { sorter:'customDateTime'}   ";

$(".tablesorter").trigger("headers",[header],"sorton",[[7,0]]);`

Please correct if this is not a correct way.

like image 400
user1173349 Avatar asked Feb 13 '26 18:02

user1173349


1 Answers

When you update the tablesorter options, you can set them as follows:

$(".tablesorter")[0].config.headers = {
    0: { sorter: false },
    1: { sorter: false },
    6: { sorter:'customDate'},
    7: {sorter:'customTime' },
    8: { sorter:'customDateTime'}
};

$(".tablesorter").trigger("update");
$(".tablesorter").trigger("sorton", [[7,0]]);

Note that setting the headers like this will remove other set header definitions, like 2: { sorter: false } will be removed from the original headers.

like image 64
Mottie Avatar answered Feb 16 '26 11:02

Mottie



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!