在tablesorter中是否有一种方法来过滤只选择字段为空的行? [英] Is there a way in tablesorter to filter to select only rows where the field is empty?
本文介绍了在tablesorter中是否有一种方法来过滤只选择字段为空的行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 filter_functions
中使用| Empty时,不应用过滤。我希望能够过滤,以显示字段为空的行。
When I use '|Empty' in filter_functions
no filtering is applied. I'd like to be able filter so that rows where the field is empty are shown.
推荐答案
我刚更新了 tablesorter fork存储库,所以在v2.21.5 +中,现在可以添加一个 filter_function
来定位空单元格,并使用 filter_selectSource
来填充选择自定义和/或所有列单元格文本作为选项( demo ):
I just updated the tablesorter fork repository, so with v2.21.5+, you can now add a filter_function
to target empty cells, and use the filter_selectSource
to populate the select with custom and/or all column cell text as options (demo):
$(function(){
$('table').tablesorter({
theme: 'blue',
widgets: ['zebra', 'filter'],
widgetOptions: {
filter_functions: {
0: {
'{empty}' : function (e, n, f, i, $r, c) {
return $.trim(e) === '';
}
}
},
filter_selectSource: {
0: function (table, column, onlyAvail) {
// get an array of all table cell contents for a table column
var array = $.tablesorter.filter.getOptions(table, column, onlyAvail);
// include the filter_function option
array.push('{empty}');
return array;
}
}
}
});
});
这篇关于在tablesorter中是否有一种方法来过滤只选择字段为空的行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文