user1173349
user1173349

Reputation: 31

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.

Upvotes: 3

Views: 2082

Answers (1)

Mottie
Mottie

Reputation: 86413

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.

Upvotes: 4

Related Questions