Search code examples
tablesorter

How to use filter after using hide on tr


I currently use tablesorter on a legacy project to add filtering and i'm stuck with a behaviour: if you manually use $("#tbody>tr").hide(), then $("#tbody>tr.someClass").show(), Filtering seems not work ( I think tablesorter lost his reference of tr... but i can't find how to told it to update his internal ref).

here an exemple of this behaviour : https://jsfiddle.net/f2qdz3dp/


Solution

  • When you use a custom theme, you'll need to add this bit of css:

    .filtered {
      display: none;
    }
    

    You can rename the css class by modifying the filter_filteredRow option.

    Also, you can set an initial search value by including a data-value attribute on the header cell:

    <td class="info" ... data-value="bla">info</td>
    

    This attribute name can also be changed using the filter_defaultAttrib option.