javascript Tablesorter - 从列中删除过滤器

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18646638/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 12:44:56  来源:igfitidea点击:

Tablesorter - Remove Filter From Columns

javascriptjquerypropertiesoptionstablesorter

提问by Howdy_McGee

I want to exclude certain columns from filtering - much like I can with sorder but I'm not sure how to do that with the widget, is there an easy way to do this?

我想从过滤中排除某些列 - 就像我可以使用排序一样,但我不确定如何使用小部件来做到这一点,有没有一种简单的方法可以做到这一点?

jQuery(document).ready(function($) {

  $("#eventTable").tablesorter({
    widthFixed : true,
    widgets: ["filter"],

    widgetOptions : {
      filter_childRows   : false,
      filter_hideFilters : false,
      filter_ignoreCase  : true,
      filter_cssFilter : 'tablesorter-filter',

      filter_functions : {
        1 : function(e, n, f, i) {
          return e === f;
        }
      }
    }
  });
});

回答by lindon

You can use either the header option or add the "filter-false" class to the TH tag for that column.

您可以使用标题选项或将“filter-false”类添加到该列的 TH 标记。

The header option is documented in the tablesorter documentation- click on "headers" in the property column of the configuration table. The syntax for the option is:

header 选项记录在tablesorter 文档中- 单击配置表的属性列中的“headers”。该选项的语法是:

headers: { 0: { filter: false} }

headers: { 0: { filter: false} }

Use the following CSS if you don't want to show the default disabled filter formatting:

如果您不想显示默认禁用的过滤器格式,请使用以下 CSS:

.tablesorter thead .disabled {display: none}

.tablesorter thead .disabled {display: none}

回答by Seralto

You can disable filter and/or sort for a specific column using:

您可以使用以下方法禁用特定列的过滤器和/或排序:

<th data-sorter="false" data-filter="false"></th>

回答by benicillin

to disable filter for specific column use <th data-filter="false"></th>

禁用特定列使用的过滤器 <th data-filter="false"></th>

to disable sort for specific column use <th data-sorter="false"></th>

禁用特定列使用的排序 <th data-sorter="false"></th>

combine them to disable both. <th data-sorter="false" data-filter="false"></th>

将它们结合起来禁用两者。 <th data-sorter="false" data-filter="false"></th>

this will cause the class "disabled" will be applied to the textbox used for filtering. The textbox will be grayed out. if you want to hide the textbox altogether, just add this

这将导致类“禁用”将应用于用于过滤的文本框。文本框将变灰。如果你想完全隐藏文本框,只需添加这个

<style>
    .tablesorter thead .disabled {
        display:none;
    }
</style>

回答by Uzay

If you want to hide all filters -before pageload- add this code to your Css file.

如果您想在页面加载之前隐藏所有过滤器,请将此代码添加到您的 Css 文件中。

.tablesorter-filter-row{
display : none;
}