I use tablesorter to sort the grid on one of my pages. I make an AJAX call every 10 seconds to update the stock information and update my grid accordingly. This works a lot, but I canβt set the sorting options correctly. Rather, I seem to have cached sorting, but when I do this, tablesorter also caches my previous rows and displays them along with a new, sorted rowset.
For example, my initial grid has 10 rows of data. I sort the second column. After 10 seconds, a new set of 10 lines appears, but my initial 10 lines still appear, although I freed them. I have researched everything and I cannot find an answer for this.
If I don't sort at all, and I don't call the trigger for "sorton", I get 10 rows as desired, but the rows are not sorted, of course. If I call this trigger for "sorton", my data is sorted, but I get 10 new lines each time the function is called (20 lines, 30 rows, etc.).
Here is my code from my AJAX call:
if (myResult.Data.length > 0) {
$.each(myResult.Data, function() {
myRows += "<tr><td>" + this.column1 + "</td><td>" + this.column2 + "</td></tr>";
});
$("#myTBody").empty();
$("#myTBody").append(myRrows).trigger("update");
var sorting = $("#myTable")[0].config.sortList;
$("#myTable").trigger("sorton", [sorting]);
}
source
share