【问题标题】:jQuery Tablesorter - Disable Sort AND FilterjQuery Tablesorter - 禁用排序和过滤
【发布时间】:2013-03-22 22:07:32
【问题描述】:

我从http://mottie.github.com/tablesorter/docs/example-options-headers.html得到这个代码:

// BONUS TIP: disable a column using jQuery data directly
// but do it before the table initializes
$("table thead th:eq(5)").data("sorter", false);

这可行,我可以添加如下所示的第二行来禁用过滤。但是,我想将它们组合成一行。我该怎么做?

// I Want to combine this into the prev line   
$("table thead th:eq(5)").data("filter", false); 

【问题讨论】:

  • 除了禁用排序和过滤并将它们合并到一行之外,还可以看看如何禁用多列。例如,在一行代码中禁用第 5 列和第 7 列中的排序和过滤。

标签: jquery filter tablesorter


【解决方案1】:

完全未经测试但试试这个

$("table thead th:eq(5), table thead th:eq(7)").data("sorter", false).data("filter", false);

【讨论】:

    【解决方案2】:

    我想补充一点,你可以结合 jQuery data 函数:

    $("table thead th:eq(5), table thead th:eq(7)").data({
        sorter: false,
        filter: false
    });
    

    【讨论】:

      【解决方案3】:

      要禁用表格单元格的排序,请在标题中添加类

      class="sorter-false" 
      

      或者您可以在“tablesorter”初始化中添加参数:

      headers : { 0 : { sorter: false } }
      

      在初始化时禁用过滤器添加参数

      headers: { 0: { filter: false} }
      

      DOM (Header) 元素,例如从 0 开始的数组

      示例

          $(".someclass").tablesorter({
              widgets : [ "filter" ],
              headers: {  0: {filter: false},
                          1: {sorter: false, filter: false},
                          2: {sorter: false}
              }
          });
      

      【讨论】:

        猜你喜欢
        • 2019-02-24
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-08-10
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多