jm_
jm_

Reputation: 641

Pre-filter in Tablesorter

How can I apply a non interactive default filter to Tablefilter?

Something like show rows where field_1="variable" but stablished by default when the table is loaded.

Thanks!

Upvotes: 0

Views: 1674

Answers (2)

James Moberg
James Moberg

Reputation: 4475

As of 2.10.8, another solution would be to add the desired filter to the header column's data-value attribute (as answered here.)

<table id="table">
  <thead>
    <tr>
      <th>...</th>
      ...
      <th data-value="abc">...</th>
  </thead>
  <tbody>
  ...
  </tbody>
</table>

More information and a sample can be found on the Custom Filter Widget Functions demo.

Upvotes: 0

Mottie
Mottie

Reputation: 86403

If I understand what you are asking, you can set the header class to "filter-false" to disable the filter in that column; then set the desired filters after the table initializes (demo):

$('table').tablesorter({
    theme: 'blackice',
    widgets: ['zebra', 'filter'],
    initialized: function (table) {
        $.tablesorter.setFilters( table, ['abc'], true);
    }
});

Upvotes: 3

Related Questions