角度材质树展开特定节点 [英] Angular material tree expand a particular node

查看:18
本文介绍了角度材质树展开特定节点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我见过使用

expandAll()

如果我们点击它,是否有任何机制可以扩展特定节点.类似的东西

Is there any mechanism to expand a particular node if we click on it. Something like

node.expand()

我参考了 angular material 文档,但没有得到任何答案.如果有人通过,请指导.

I had referred angular material documentation but not got any answer. Please guide if anyone gone through it.

推荐答案

你要找的是 treeControl 上的 expand 方法,它对 进行操作treeControl.dataNodes 数组.

What you are looking for is the expand method on treeControl, which operates on the treeControl.dataNodes array.

类似的东西

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.

演示

这篇关于角度材质树展开特定节点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆