question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Searching the tree (similar to filter)

See original GitHub issue

Hi, 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:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
adamkleingitcommented, Dec 4, 2016

Currently there’s no built-in iteration over treeNodes, but I can add it.

Something like this maybe:

treeModel.forEachNode((node) => ...)

?

0reactions
marcolazzaracommented, Jul 18, 2017

Hi,

can you please post a full example about using filter?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found