سؤال

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;
        }
      }
    }
  });
});
هل كانت مفيدة؟

المحلول

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}

نصائح أخرى

You can disable filter and/or sort for a specific column using:

<th data-sorter="false" data-filter="false"></th>

to disable filter for specific column use <th data-filter="false"></th>

to disable sort for specific column use <th data-sorter="false"></th>

combine them to disable both. <th data-sorter="false" data-filter="false"></th>

this will cause the class "disabled" will be applied to the textbox used for filtering. The textbox will be grayed out. if you want to hide the textbox altogether, just add this

<style>
    .tablesorter thead .disabled {
        display:none;
    }
</style>

If you want to hide all filters -before pageload- add this code to your Css file.

.tablesorter-filter-row{
display : none;
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top