我在ExtJS 4.2.1.
树数据显示在面板中,但每次我展开节点时,我在节点下面得到相同的信息,因此无限。
我没有得到真正的儿童用品。你可以理解json响应有父节点的子节点,但每次我扩展一个节点时,我的服务的ajax调用就完成了,因此我再次得到所有的树数据结构。
这是我的json:
[
{
"text": "QUALITY AREA",
"cls": null,
"expanded": false,
"checked": false,
"leaf": false,
"children": [
{
"text": "JUNIOR A",
"cls": null,
"expanded": false,
"checked": false,
"leaf": true,
"children": null
}
]
},
{
"text": "HUMAN RESOURCES",
"cls": null,
"expanded": false,
"checked": false,
"leaf": false,
"children": [
{
"text": "SENIOR C",
"cls": null,
"expanded": false,
"checked": false,
"leaf": true,
"children": null
}
]
},
{
"text": "IT DEPARTMENT",
"cls": null,
"expanded": false,
"checked": false,
"leaf": false,
"children": [
{
"text": "JUNIOR E",
"cls": null,
"expanded": false,
"checked": false,
"leaf": true,
"children": null
}
]
},
{
"text": "TRAINING",
"cls": null,
"expanded": false,
"checked": false,
"leaf": false,
"children": [
{
"text": "JUNIOR F",
"cls": null,
"expanded": false,
"checked": false,
"leaf": true,
"children": null
}
]
},
{
"text": "BENEFITS & COMP",
"cls": null,
"expanded": false,
"checked": false,
"leaf": false,
"children": [
{
"text": "SENIOR D",
"cls": null,
"expanded": false,
"checked": false,
"leaf": true,
"children": null
}
]
},
{
"text": "ADMIN",
"cls": null,
"expanded": false,
"checked": false,
"leaf": false,
"children": [
{
"text": "CHIEF A",
"cls": null,
"expanded": false,
"checked": false,
"leaf": true,
"children": null
}
]
}
],
这是我的treepanel:
{
xtype: 'treepanel',
itemId: 'treepaneltest',
store: store,
rootVisible: false,
useArrows: true,
frame: true,
title: 'Check Tree',
width: 500,
height: 250,
}
我是否需要更改json
中的内容?
答案 0 :(得分:0)
你能展示商店吗?
理想情况下,树存储应如下所示。
Ext.define('MyApp.store.Hierarchies',{
extend: 'Ext.data.TreeStore',
model : 'MyApp.model.Hierarchy',
proxy: {
type: 'ajax',
url: 'path-to-json-file.json',
},
root: {
text: 'Root',
id: 'root',
iconCls: 'cls',
expanded: false,
}
});