2016-09-28 57 views
1

我找到了一个过滤器配置以过滤空列。 问题是我只知道如何将其应用于一列(在示例列号8中)。我想将其同时应用于其他列(例如第8,12和17列)。 谢谢!Tablesorter将过滤器设置设置为多列

filter_functions: { 
      8: { 
       '{empty}' : function (e, n, f, i, $r, c) { 
        return $.trim(e) === ''; 
       } 
      } 
     }, 
     filter_selectSource: { 
      8: function (table, column, onlyAvail) { 
       // get an array of all table cell contents for a table column 
       var array = $.tablesorter.filter.getOptions(table, column, onlyAvail); 
       // manipulate the array as desired, then return it 
       array.push('{empty}'); 
       return array; 
      } 
     }, 

回答

0

两者filter_functionsfilter_selectSource选项将接受含有jQuery选择的对象键,以及一个从零开始的列索引。例如,如果列标题8,12和17都具有类别名称“add-empty”,则设置选项如下:

filter_functions: { 
    '.add-empty' : { 
    '{empty}' : function (e, n, f, i, $r, c) { 
     return $.trim(e) === ''; 
    } 
    } 
}, 
filter_selectSource: { 
    '.add-empty' : function (table, column, onlyAvail) { 
    // get an array of all table cell contents for a table column 
    var array = $.tablesorter.filter.getOptions(table, column, onlyAvail); 
    // manipulate the array as desired, then return it 
    array.push('{empty}'); 
    return array; 
    } 
} 
+0

谢谢先生Mottie !!我还发现,如果在常规过滤器中点击:“”您也只会过滤空单元格。 –

+0

对不起,点击什么? – Mottie

+0

只需打开并关闭像这样的双引号 - >“” –