Question

I use the tablesorter 2.0, and I update the cells' value with ajax. After the call I would need to order again the rows, but the $('#thisTable').trigger('update') don't help me.

I dealing with markup inside cells, but it can't be problem.

 $('#thisTable').tablesorter({
   textExtraction: function(node) {
     return node.getElementsByTagName('input')[0].value; 
   }
 });

Any help would be appreciated.

-- Kree

Was it helpful?

Solution

You can find the answer in table sorter docs. You have to trigger another event sorton.

OTHER TIPS

This is my code

//append some content to the tbody
$('table').trigger('update');    
var $sort = $('table').get(0).config.sortList;
$("table").trigger("sorton",[$sort]); 

The above is called after I add some rows to the table body. I am able to see the $sort values but the trigger function is not sorting the newly added rows.

I've have a small change in the source code. I've added a parameter to the update event handler to ask for sorting.

$("#MyTable").trigger('update') will work as usual.

$("#MyTable").trigger('update', true) will ask for sorting after the update.

$this.bind("update", function (e, sort) {
   var me = this;
   setTimeout(function () {
       // rebuild parsers.
       me.config.parsers = buildParserCache(
       me, $headers);
       // rebuild the cache map
       cache = buildCache(me);
       // ADDED
       if (sort) $(me).trigger('sorton', [me.config.sortList]);
   }, 1);
});

Regarding to the implementation of the "update" event, it executes the update after a timeout of 1ms. eather this function should be rewritten in the table sorter, eather using a callback.

$this.bind("update", function () {
  var me = this;
  setTimeout(function () {
    // rebuild parsers.
    me.config.parsers = buildParserCache(
    me, $headers);
    // rebuild the cache map
    cache = buildCache(me);
}, 1);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top