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
使用自定义和/或所有列单元格文本作为选项(演示):
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屋!
查看全文