我的树结构与下面相同
var tree = [
{
text: "Parent 1",
nodes: [
{
text: "Child 1",
type: "Child",
nodes: [
{
text: "Grandchild 1"
type: "Grandchild"
},
{
text: "Grandchild 2"
type: "Grandchild"
}
]
},
{
text: "Child 2",
type: "Child"
}
]
},
{
text: "Parent 2",
type: "Parent"
},
{
text: "Parent 3",
type: "Parent"
}
];
同How to effectively filter tree view retaining its existing structure?
唯一的区别是在example1中,如果我们搜索parent 1,它将返回空节点[],因为没有一个子节点包含文本“Parent 1”