Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/extjs/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Extjs Ext JS树,在我展开根节点之前childNodes为空(加载完整树结构)_Extjs_Tree - Fatal编程技术网

Extjs Ext JS树,在我展开根节点之前childNodes为空(加载完整树结构)

Extjs Ext JS树,在我展开根节点之前childNodes为空(加载完整树结构),extjs,tree,Extjs,Tree,我第一次加载完整的树结构 var tree = new Ext.tree.TreePanel({ title : 'Simple Tree', width : 300, height : 300, root : new Ext.tree.AsyncTreeNode({ children : [ { text : 'one', leaf : true }, { text : '

我第一次加载完整的树结构

var tree = new Ext.tree.TreePanel({
    title   : 'Simple Tree',
    width   : 300,
    height  : 300,
    root    : new Ext.tree.AsyncTreeNode({
        children : [
            { text :  'one',    leaf : true },
            { text :  'two',    leaf : true },
            { text :  'three',  leaf : true }
        ]
    })
});
Ext.onReady(function(){
    tree.render(Ext.getBody());
});
试试这个

treePanel.root.childNodes // []
但在我展开根节点并重试之后

treePanel.root.childNodes // [obj, obj, obj]

我可以在不展开根节点的情况下获取childNodes吗?

似乎
childNodes
只填充了实际元素。在展开该节点之前,不需要它们


您要查找的是
treePanel.root.attributes.children
。这其中有三个元素。

@amol,我更新了一个示例代码。如果我确实需要childNodes(出于复选框原因,当我选中父节点时,所有childNodes都已选中,但不需要展开),那么我该怎么办?