【问题标题】:jQuery Tablesorter and sortListjQuery Tablesorter 和 sortList
【发布时间】:2013-08-15 17:23:15
【问题描述】:

我正在使用 jQuery tablesorter 插件 (http://mottie.github.io/tablesorter/docs/index.html)

tablesorter 正在工作,我可以使用此代码禁用对列的排序和过滤。

// Disable sorting and filtering on 1st column
$("table thead th:eq(0)").data("sorter", false).data("filter", false);

我怎样才能使用 .data 方法来做同样的事情?

$("table").tablesorter({ 
// sort on the 4th column, order asc 
sortList: [[3,0]] 
});

我的问题是我无法确定如何使用 sortList: [[3,0]] 和 .data 语法。任何建议将不胜感激。

【问题讨论】:

    标签: tablesorter


    【解决方案1】:

    嗯,你可以使用这样的数据函数来更新保存的排序,但是你需要实际触发一个排序来应用它:

    $("table").data('tablesorter').sortList = [[3,0]];
    $("table").trigger('update'); // apply the new sort
    

    但实际上,我认为您最好的选择是触发 sorton 事件:

    $("table").trigger("sorton", [[3,0]]);
    

    【讨论】:

    • Mottie - 非常感谢您的回复。
    • 不幸的是,我收到一个错误“数据为空或不是对象”
    • 我只能猜测错误来自使用第一个sn-p。只需确保 tablesorter 在使用前已初始化。
    【解决方案2】:

    这样的“排序事件”

    $("table").trigger("sorton", [[[3,0]]]);
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多