[英]dojo dijit.tree getChildren() not returning all tree nodes
I am using dojo 1.10.4 and have noticed that the dijit.tree getChildren() function only returns children (tree) nodes that are expanded (displayed and visible) in the dijit.tree.我正在使用 dojo 1.10.4 并且注意到 dijit.tree getChildren() 函数只返回在 dijit.tree 中展开(显示和可见)的子(树)节点。 How can I loop through all of the dijit.tree tree nodes regardless of whether or not they are displayed and visible?如何循环遍历所有 dijit.tree 树节点,而不管它们是否显示和可见?
Any suggestions are greatly appreciated.任何建议都非常感谢。
I'm not sure if this is what you are after, but that's how we are expanding all the nodes, which is similar to your task, getting all the nodes from the tree.我不确定这是否是您所追求的,但这就是我们扩展所有节点的方式,这与您的任务类似,从树中获取所有节点。 I believe with a simple modification you will be able to achieve your task我相信通过简单的修改,您将能够完成您的任务
Assume that we have a function for expanding the tree nodes, which we are going to call假设我们有一个扩展树节点的函数,我们将调用它
this._expandTree(this._tree.rootNode);
and the function itself和函数本身
_expandTree: function (node) {
if (node.hasChildren()) {
var currentNode;
for (var i = 0; i < node.getChildren().length; i++) {
currentNode = node.getChildren()[i];
this._expandTree(currentNode);
}
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.