【问题标题】:Returning only the filtered tree from fancytree仅返回从 fancytree 过滤的树
【发布时间】:2019-07-14 23:44:06
【问题描述】:
请帮忙。
这可能很简单,但我已经坚持了好几天了。
正如标题所说,我只想获得过滤后的树,包括fancytree 中的父节点(用于json 目的)。
我看过ext-filter,但它似乎没有直接提供任何getRootNode 或findAll 函数。
如何检索树的过滤版本?
【问题讨论】:
标签:
javascript
json
filter
fancytree
【解决方案1】:
可以这样穿:
var nodeList = tree.toDict(false, function(d, node){
if( !node.isMatched() && !node.subMatchCount) {
return false;
}
});
(注意:toDict 回调仅从 Fancytree 2.32 版开始支持返回 false。在此之前,您必须使用 tree.visit(callback)、node.toDict(false) 等解决方法)