开发者

Sort entire data with tablesorter jQuery

I am using tablesorter for sorting my tables. But it seems to sort only the visible data in my table. Suppose I have 100 records numbered 1 to 100 and I display only 10 records at a time, then when I sort a particular column, only those 10 records are sorted ascendingly(1->10) or descendingly(10->1). But I need the entire data to be sorted(i.e in the table I should get 1->10 or 100->91). How is that possible?

This is the code I use for sorting:

 $(".tableSort").tablesorter({
    cssAsc:'asc',
    cssDesc:'desc',
    sortList:[[0,0]],
    widgets:['zebra']
 });

EDIT: I had noticed now that when I move to the next page, 开发者_运维知识库i.e, the second page, there I get the numbers as 90-81 (the entire data has been sorted in descending order). And When I move back to the first page, I get the numbers as 100-91. But Initially it is displayed as 10-1. What is the reason? How do I resolve this?


What you need to do is create a tag and not display it like

var table = $('<table></table>');

the add all the data to that tag and then do

table.tablesorter({
    cssAsc:'asc',
    cssDesc:'desc',
    sortList:[[0,0]],
    widgets:['zebra']
 });

The reason it is sorting what is displayed, is because your selecting the table that is displayed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜