【发布时间】:2020-02-10 13:01:15
【问题描述】:
我在“Filter on Tree or Nested Data #1562”一期中看到 Oli 提到过
嘿@fr0z3nfyr 自版本 4,2 起,树子节点支持过滤 干杯 奥利:)
我找不到任何示例或代码来搜索嵌套数据。 我的代码在平面表中工作得很好,但对于嵌套表,它只适用于根节点。
//data - the data for the row being filtered
//filterParams - params object passed to the filter
var match = false;
for (var key in data) {
if (data[key] != null) {
if ((data[key]).indexOf(filterParams.value) != -1) {
match = true;
}
}
}
return match;
}
function updateFilter(){
if ($("#filter-field").val() == "All Columns") {
table.setFilter(matchAny,{ value: $("#filter-value").val()});
} else {
table.setFilter($("#filter-field").val(), "like", $("#filter-value").val());
}
//var filter = $("#filter-field").val() == "All Columns" ? matchAny : $("#filter-field").val() ;
}```
Oli could you please point me to an example where Nested data filtering is supported
【问题讨论】:
-
这里是一个不那么冗长的递归实现:stackoverflow.com/a/68155905/7576114