How to reset column filters

Even though there is no built-in feature to reset the table column filters, you can do that by using the following Javascript code:


jtQuery( document ).ready(function() {  
  
  resetColumnFilters = function(table_order) {    
    var oTable = tabulizer_datatables[table_order];
    var table_id = oTable.attr('id');
    var i, filter_index, filter_value = '';      
    
    jtQuery('#' + table_id + ' input').each(
      function(index){  
        var input = jtQuery(this);
        var name = input.attr('name');                
        var regex = new RegExp('tab_search_col_'+table_order+'_(\\d+)','i');        
        var m = regex.exec(name);
        if (m) {
          filter_index = m[1];          
          oTable.fnFilter( filter_value, filter_index );  
          jtQuery( "input[name='"+name+"']").val(filter_value);
          jtQuery( "input[name='"+name+"']").focus();            
          jtQuery( "input[name='"+name+"']").blur();            
        }              
      }
    );
    
    jtQuery('#' + table_id + ' select').each(
      function(index){  
        var input = jtQuery(this);
        var name = input.attr('name');                
        var regex = new RegExp('tab_search_col_'+table_order+'_(\\d+)','i');        
        var m = regex.exec(name);
        if (m) {
          filter_index = m[1];          
          oTable.fnFilter( filter_value, filter_index );  
          jtQuery( "select[name='"+name+"']").prop('selectedIndex',0);
        }              
      }
    );          
  }
            
});  

Here is how you can use it

Step #1: Download the javascript file reset-filters.js from here and place it under the following path:

  • {joomla root directory}/templates/tabulizer/js for Joomla users
  • {joomla root directory}/templates/tabulizer/js for Wordpress users
Don't forget to unzip it first :)

Step #2: Add a rule that will include this javascript file and option append (or prepend) the HTML code that will call this function. Check out the sample rule below: