Searching the tree (similar to filter)
See original GitHub issueHi, what is the best way to search for a node in the tree by some function (just like filter), but without any side effects (ex: filter is hiding the nodes). I just want to receive the list of nodes. I need this to programatically focus a node on the tree that his name contains something (I will focus the first node of the filtered list)
The true flag in the filterNodes is still hiding the ones that did not match the comparison. I just want to list back. I can of course iterate the tree on my own recursively but maybe there is already an easier way 😃
Edit: Searching like this seems to be okay:
let arr = []
let iter = (node) => {
arr.push(...node.filter(child => {
if (child.children)
iter(child.children);
return child.data.key == this.displayedNode.value.patternKey
}));
}
iter(this.tree.treeModel.roots);
console.log(arr)
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to search filter in a tree-like structure? - Stack Overflow
Write helper method to first find the object which contained the criteria of having given grand child text, then update the found object...
Read more >Beautiful Soup - Searching the tree - Tutorialspoint
Kinds of Filters. We have different filters which we can pass into these methods and understanding of these filters is crucial as these...
Read more >Search in hierarchy filters - TIBCO Product Documentation
The tree structure in a hierarchy filter can be extensive. To find specific parts in the hierarchy, you can type what you are...
Read more >3. Search and advanced filters - TreeGrid
Search provides advanced searching and filtering in grid. It provides three methods of searching (search like Google, search by expression and exact ...
Read more >Smart Filtering - Ancestry Support
Smart Filtering helps focus your search on new information by removing less helpful results. Smart Filtering removes:.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Currently there’s no built-in iteration over treeNodes, but I can add it.
Something like this maybe:
?
Hi,
can you please post a full example about using filter?