ExtJS treepanel 没有得到真正的子项
Posted
技术标签:
【中文标题】ExtJS treepanel 没有得到真正的子项【英文标题】:ExtJS treepanel not getting real children items 【发布时间】:2014-11-18 02:06:52 【问题描述】:我在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
]
],
这是我的树形面板:
xtype: 'treepanel',
itemId: 'treepaneltest',
store: store,
rootVisible: false,
useArrows: true,
frame: true,
title: 'Check Tree',
width: 500,
height: 250,
我是否必须更改我的 json
中的某些内容?
【问题讨论】:
需要设置loaded: true
,否则展开节点时会再次尝试加载。
我必须在哪里设置该属性?
在您的 json 中添加 'loaded:true' 属性,如 'checked'
【参考方案1】:
你能介绍一下商店吗?
理想情况下,树形存储应如下所述。
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,
);
【讨论】:
以上是关于ExtJS treepanel 没有得到真正的子项的主要内容,如果未能解决你的问题,请参考以下文章
无法在 extjs 4 的 Treepanel 中显示 json 数据
ExtJS - 将 Treepanel 节点向上/向下移动代码
在 ExtJs 4.0 TreePanel 中更改文件夹和叶子节点的顺序