Sergio HV
Sergio HV

Reputation: 61

Tablesorter hide filters of hidden columns

I'm trying to use the tablesorter plugin in my html table.

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).

The problem is that Tablesorter don't hide the filters of the hidden columns.

enter image description here

What I need is to display:none the filters that its TH is already display:none.

Thank you and ask me if you need further details.

Upvotes: 5

Views: 2617

Answers (1)

Mottie
Mottie

Reputation: 86403

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.

    // 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

    #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.

Upvotes: 5

Related Questions