Angular material tree expand a particular node

╄→尐↘猪︶ㄣ 提交于 2020-02-06 04:09:25

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/55590162/angular-material-tree-expand-a-particular-node

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!