Guides
Guides

Filtering on the tree is not trivial, since the filtering process needs the keep the tree structure.
For example, if one of the nodes is visible - we must display its parent, and grandparent etc.
This is being taken care of by the treeModel 'filterNodes' function.

Filter by function

The function receives the node and returns true if the node should be hidden, false otherwise.

tree.treeModel.filterNodes((node) => {
  return !node.data.name.startsWith(text);
});

Filter by string

The function filters all nodes whose displayField ('name' by default) contains the given string. The comparison is done case insensitive.

tree.treeModel.filterNodes("text", true);

Note the second field - true by default.
This flag makes sure all nodes are visible after searching (i.e. expand all relevant ancestors).

Manual filtering

If you need a different behaviour than the above, you can traverse the tree and do your own magic, and call hide(), show(), or setIsHidden(value) on all nodes as you wish.