Reputation: 250
How to Show childNodes in extjs treePanel if parent Node is filtered
As you can see the fiddle you can filter any parent Node but child will be hidden, but when you search child parent will be visible.
I want to see parent in the both the cases. Either filtering child/parent always parent should be there. if child filtered respective parent stay there , this is already there in extjs
Upvotes: 2
Views: 1293
Reputation: 3629
You need to add code to the filter function, so it also checks parent nodes.
In the filterFn, if (!visible) {
add:
var parent = node.parentNode;
var testVisible = false;
while(parent){
testVisible = v.test(parent.get('text'))
if(testVisible){
visible = testVisible;
break;
}
parent = parent.parentNode;
}
Fiddle https://fiddle.sencha.com/#view/editor&fiddle/1oso
Upvotes: 4
Reputation: 632
You can check if current node parents are valid by adding this right after you check if the nodes' children validate:
if (!visible) {
var current = node;
while (current.parentNode) {
current = current.parentNode;
if (v.test(current.get('text'))) {
visible = true;
break;
}
}
}
Here is the updated fiddle.
Upvotes: 1