Angular material tree expand a particular node
15,820
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.
Author by
androidGenX
Like to try different languages. Likes R&D. Now sticking to java. Have worked on ios, android, php before.
Updated on July 21, 2022Comments
-
androidGenX almost 2 years
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.
-
Nayan Hodar about 4 yearsHow to expand all parent node of particular child node in nested tree control in angular 8??? I used this code with some extra fields modification stackblitz.com/angular/…
-
C0mpl3x about 3 yearsWhat is I want to pass in a specific node to open that was clicked. How do I do that. I cannot pass the node because your sollution need index.