使用tablesorter jQuery对整个数据进行排序 [英] Sort entire data with tablesorter jQuery

查看:214
本文介绍了使用tablesorter jQuery对整个数据进行排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用tablesorter对我的表进行排序.但是它似乎只对表中的可见数据进行排序.假设我有100条记录,编号为1到100,并且一次只显示10条记录,那么当我对特定的列进行排序时,只有这10条记录按升序(1-> 10)或降序(10-> 1)排序.但是我需要对整个数据进行排序(即在表中我应该得到1-> 10或100-> 91).那怎么可能?

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']
 });

我现在注意到,当我移至下一页(即第二页)时,我得到的数字为90-81(整个数据已按降序排序).当我回到第一页时,我得到的数字是100-91.但是最初它显示为10-1.是什么原因?我该如何解决?

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.

这篇关于使用tablesorter jQuery对整个数据进行排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆