dojo dijit.tree getChildren() 未返回所有树节点

dojo dijit.tree getChildren() not returning all tree nodes

我正在使用 dojo 1.10.4 并注意到 dijit.tree getChildren() 函数仅 returns 在 [=22] 中扩展(显示和可见)的子(树)节点=].我如何循环遍历所有 dijit.tree 树节点,而不管它们是否显示和可见?

非常感谢任何建议。

我不确定这是不是你想要的,但这就是我们扩展所有节点的方式,这类似于你的任务,从树中获取所有节点。我相信通过简单的修改你就能完成你的任务

假设我们有一个扩展树节点的函数,我们将调用

    this._expandTree(this._tree.rootNode);

和函数本身

    _expandTree: function (node) {
                if (node.hasChildren()) {
                    var currentNode;
                    for (var i = 0; i < node.getChildren().length; i++) {
                        currentNode = node.getChildren()[i];                            
                        this._expandTree(currentNode);
                    }
                }
            },