最后,在与extjs树面板、树存储和构建自定义读取器以读取和转换宾得数据2周之后,我成功地将戊and数据加载到extjs的treepanel中。
现在,我的Tree面板正在无限地加载相同的数据。Treepanel看起来如下:

json数据的一部分如下所示:
{
{name: 'US', candidateCount: 3, children: []},
{name: 'India', candidateCount: 922, children: [
{name: 'Goa', candidateCount:124, children: []},
{name: 'Maharashtra', candidateCount: 43, children: [
{name: 'Pune', candidateCount: 3},
{name: 'Mumbai', candidateCount: 33},
{name: 'Kolhapur', candidateCount: 4},
{name: 'XXX', candidateCount: 3},
]}
]},
{name: 'UK', candidateCount: 1, children: []},
}如上图所示,在展开India节点后,它再次加载了国家级别的数据(即国名美国、英国、印度、英国)。实际上,我想显示状态级别的数据,比如Maharashtra,Goa的数据。取而代之的是treepanel再次加载相同的数据。
如何避免这种行为?我已经将美国、英国和印度节点的leaf属性设置为false。
我尝试将Expanded属性设置为true,但是treepanel一次又一次地加载相同的节点,我的浏览器选项卡就挂起了。
请告诉我如何避免这件事?我希望树面板只加载一次数据。
编辑-解决这个问题
我通过在存储的append事件上添加侦听器来解决这个问题,然后将leaf值设置为要成为叶节点的true。
发布于 2012-02-16 13:35:17
将数据项设置为:
{
...
leaf: true
}会阻止它的。
发布于 2012-02-28 16:26:42
我的treepanel和JSON数据也有同样的问题。我的treeStore看起来是这样的:
proxy: {
type: 'ajax',
url: 'urlJson',
reader: {
type: 'json',
root: 'instanceList',
successProperty: 'success'
}
},
root:{
text: 'Root',
expanded: true
}和JSON
{
"instanceList": [
{
"text": "Parent 1",
"instanceList": [
{
"class": "testing",
"id": 3,
"leaf": true,
"text": "Child 1"
}
]
},
{
"text": "Parent 2",
"instanceList": [
{
"class": "testing",
"id": 2,
"leaf": true,
"text": "Child 2"
},
{
"class": "testing",
"id": 1,
"leaf": true,
"text": "Child 3"
}
]
}
],
"instanceTotal": 1,
"success": true
}我把"instanceList“改成了”子“,我的树终止了这个无限循环,所以我想如果您将”名称“改为”子“?
发布于 2012-02-16 13:33:57
装载树木可能是骗人的。尝试在这些节点上设置loaded: true。在开始单击之前,树是否已正确加载?
https://stackoverflow.com/questions/9311410
复制相似问题