Tablesorter - Remove Filter From Columns

Howdy_McGee picture Howdy_McGee · Sep 5, 2013 · Viewed 15k times · Source

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;
        }
      }
    }
  });
});

Answer

lindon picture lindon · Sep 6, 2013

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

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:

headers: { 0: { filter: false} }

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

.tablesorter thead .disabled {display: none}