简体   繁体   English

Tablesorter隐藏隐藏列的过滤器

[英]Tablesorter hide filters of hidden columns

I'm trying to use the tablesorter plugin in my html table. 我正在尝试在我的html表中使用tablesorter插件。

The issue is that I have some "display:none" columns that only are shown if I click a toggle button (my table is very long and I need this functionality). 问题是我有一些“display:none”列只有在我点击一个切换按钮时才显示(我的表很长,我需要这个功能)。

The problem is that Tablesorter don't hide the filters of the hidden columns. 问题是Tablesorter不会隐藏隐藏列的过滤器。

在此输入图像描述

What I need is to display:none the filters that its TH is already display:none. 我需要的是显示:没有其TH已经显示的过滤器:无。

Thank you and ask me if you need further details. 谢谢你,问我是否需要进一步的细节。

There are several methods to hide the filter cells: 有几种方法可以隐藏过滤单元格:

  • Whatever class you are adding to hide the column, include it in the filter_cellFilter option in an array. 无论要添加哪个类来隐藏列,都要将其包含在数组的filter_cellFilter选项中。

     // hiding second & fourth columns using associated css filter_cssFilter : [ '', 'hidden', '', 'hidden' ] 
  • Use the following css to hide the entire column instead of adding a class to each cell within the column 使用以下css隐藏整个列,而不是向列中的每个单元格添加类

     #mytable th:nth-child(10), #mytable td:nth-child(10), #mytable th:nth-child(11), #mytable td:nth-child(11), #mytable th:nth-child(12), #mytable td:nth-child(12) /* etc */ { display: none; } 

I am also curious as to why you would need so many hidden columns. 我也很好奇你为什么需要这么多隐藏的专栏。 It is also possible to add the extra values in data-attributes, then with some special parsing you can sort or filter using that extra data. 也可以在数据属性中添加额外的值,然后通过一些特殊的解析,您可以使用该额外数据进行排序或过滤。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM