我试图使用引导表来显示我的数据,我希望过滤指定单元格为空的行,并且不希望它们出现。
$('#tableId').bootstrapTable('refreshOptions', {
filterOptions: {
filterAlgorithm: "not"
}
});
$('#@tableId').bootstrapTable('filterBy', {"specifiedCell":""});遗憾的是,filterAlgorithm在上面的代码中不支持not。
我应该在filterAlgorithm前面写些什么来使用自定义过滤器?
发布于 2022-04-09 07:09:55
我在互联网上没有看到任何关于它的很好的解释,但是通过测试,我明白自定义过滤器模板是这样的:
$('#tableId').bootstrapTable('refreshOptions', {
filterOptions: {
filterAlgorithm: function (row, filter) {
if(row['specifiedCell'] != filter['specifiedCell']){ //check row or row[cell] condition by `filter`
return true;//it will the `row` will display.
} else {
return false;//it wont show the `row`
}
}
}
});
$('#@ViewBag.dynamicData["tableId"]').bootstrapTable('filterBy', {
"specifiedCell":""
});在上面的代码中,我用包含不应该在表上的值的筛选器检查了行中指定的单元格,因此,通过在未处于筛选器时返回true,我使自定义无效。
https://stackoverflow.com/questions/71752518
复制相似问题