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

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

问题描述

我已经看到了使用扩展mat-tree中所有节点的各种示例

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.

推荐答案

您正在寻找的是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天全站免登陆