Ext JS 树,在展开根节点之前 childNodes 为空(加载完整的树结构)
我第一次加载完整树结构。
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]
我可以在不展开根节点的情况下获取子节点吗?
I load FULL tree structure at first time.
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());
});
and try this..
treePanel.root.childNodes // []
But after I expand root node and try again
treePanel.root.childNodes // [obj, obj, obj]
Can I get childNodes without expand root node ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来
childNodes
仅填充了实际元素。在扩展该节点之前,不需要它们。您正在寻找的是
treePanel.root.attributes.children
。其中包含三个要素。It appears that
childNodes
is only populated with actual elements. Before you expand that node they are not needed.What you are looking for is
treePanel.root.attributes.children
. That has three elements in it.