【问题标题】:tablesorter jQuery hack表格排序器 jQuery hack
【发布时间】:2011-03-10 20:17:06
【问题描述】:

我正在尝试破解 tablesorter jQuery 插件,但没有成功。我想要的是这个……

我有一个表格(运动队列表),并且有一行设置为特定的班级。这基本上是为了展示决赛系列赛的资格,所以它必须始终留在那个地方。例如。如果有人按胜利对表格进行排序,我仍然希望第 8 行有我一开始给它的类:

$("table.ladder tr:nth-child(8)").addClass("finals");

由于tablesorter目前是这样,当table被排序时,这个TR显然会移动。像这样让 tablesorter 保持第 n 行的最佳方法是什么?

希望这是有道理的!

【问题讨论】:

  • Im not that I understand what you want to do. If you want a specific "tr" to stay at one place, you should sort the table by field, that wont 更改“获胜”的顺序。这是按多个标准进行的排序。

标签: javascript jquery tablesorter


【解决方案1】:

tableSorter 有一个名为“sortEnd”的 under-documented internal function,您可以将其绑定到...

$("table.ladder")  
 .tablesorter()  
 .bind("sortEnd", function(){  
   $("table.ladder tr").removeClass("finals");
   $("table.ladder tr:nth-child(8)").addClass("finals");

})

我假设您只想移动班级,而不是数据。如果您有一个始终应该位于底部的数据行,您可以使用<thead/><tbody/><tfoot/> 结构并将该行放在<tfoot/>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-10
    • 1970-01-01
    • 2016-07-31
    • 2013-02-04
    相关资源
    最近更新 更多