I have seen various examples to expand all nodes in mat-tree using
expandAll()
Is there any mechanism to expand a particular node if we click on it. Something like
node.expand()
I had referred angular material documentation but not got any answer. Please guide if anyone gone through it.
What you are looking for is the expand
method on treeControl
, which operates on the treeControl.dataNodes
array.
Something like
this.treeControl.expand(this.treeControl.dataNodes[/** node you want to expand **/]);
Just keep in mind that if you want to expand a particular node, all its ancestors up to the root need to be expanded as well.
Demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With