在jquery中对多个表进行排序
我们一直在使用jquery tablesorter.js对表行进行排序。但最近我们不得不将表拆分为多个表,滚动条才能处理固定列。这工作正常,但排序功能消失了。我们不能在多个表上再使用tablesorter 有人能建议使用tablesorter.js或不使用tablesorter.js的解决方案吗? HTML:在jquery中对多个表进行排序,jquery,asp.net-mvc,Jquery,Asp.net Mvc,我们一直在使用jquery tablesorter.js对表行进行排序。但最近我们不得不将表拆分为多个表,滚动条才能处理固定列。这工作正常,但排序功能消失了。我们不能在多个表上再使用tablesorter 有人能建议使用tablesorter.js或不使用tablesorter.js的解决方案吗? HTML: 说明文字 A1 A2 A3 A4 总数 08/19 08/21 08/26 09/09 09/23 23 1. 4. 45 56 20 21 02 03 54 3. 2. 2. 1. 3
说明文字
A1
A2
A3
A4
总数
08/19
08/21
08/26
09/09
09/23
23
1.
4.
45
56
20
21
02
03
54
3.
2.
2.
1.
32
平均等级
0.45
0.236
0.6
0.98
0.21
检查此示例
$('table').tablesorter();
// using a flag that prevents recursion - repeatedly calling this same function,
// because it will trigger the "sortEnd" event after sorting the other tables.
var recursionFlag = false;
// bind to table sort end event on ALL tables
$("table").bind("sortEnd",function(e, table) {
// ignore if the flag is set
if (!recursionFlag) {
recursionFlag = true;
// find other tables to resort (but not the current one)
// the current sort is stored in "table.config.sortList"
$('table').not(this).trigger("sorton", [ table.config.sortList ]);
// reset recursion flag after 1 second... so you can't sort faster
// than that or it won't trigger the other tables
// you can adjust this value; it all depends on how much data needs
// to be sorted in the tables. Run the tablesorter with "debug:true"
// to find out the times needed to sort (but do it in IE as it is
// the slowest browser)
setTimeout(function(){ recursionFlag = false; }, 1000);
}
});
它不起作用。。要传递给它的表id是什么?不需要传递id,这里使用公共表标记名。然后,如果单击tbl2中的标题,则只对表tbl2数据进行排序。其他表中这些行的相应列不会按照排序进行重新排序。。有什么解决方法吗?你有多个表。当你点击一个表时,在那个特定的表上,属性只起作用。这就是..我的数据是单表视图,但从技术上讲,它被分成多个表,排序应该适用于所有表。我正在寻找解决这个问题的办法。
$('table').tablesorter();
// using a flag that prevents recursion - repeatedly calling this same function,
// because it will trigger the "sortEnd" event after sorting the other tables.
var recursionFlag = false;
// bind to table sort end event on ALL tables
$("table").bind("sortEnd",function(e, table) {
// ignore if the flag is set
if (!recursionFlag) {
recursionFlag = true;
// find other tables to resort (but not the current one)
// the current sort is stored in "table.config.sortList"
$('table').not(this).trigger("sorton", [ table.config.sortList ]);
// reset recursion flag after 1 second... so you can't sort faster
// than that or it won't trigger the other tables
// you can adjust this value; it all depends on how much data needs
// to be sorted in the tables. Run the tablesorter with "debug:true"
// to find out the times needed to sort (but do it in IE as it is
// the slowest browser)
setTimeout(function(){ recursionFlag = false; }, 1000);
}
});