作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 JSON 数据创建 Extjs 树。我想要加载到树中的数据包含文件夹结构。但是当我尝试将数据加载到树中时,它没有显示任何内容。
我检查了json代码here (JSONLint)出现错误,但一切看起来都很好。这说明问题可能出在 extjs 部分。
我不知道如何让它发挥作用。
我创建了一个像这样的 JSON 对象:
{
"folders": [
{
"name": "Function",
"id": "workspace://SpacesStore/000-000-000",
"folders": [
{
"name": "Evaluation reports",
"id": "workspace://SpacesStore/00-00-4949-9caf-6655fg"
},
{
"name": "Function Reports",
"id": "workspace://SpacesStore/554gg-563-sd555-872e-0098hhjf"
},
{
"name": "Training(POP)",
"id": "workspace://SpacesStore/4334g-67hj-4357-ba96-4343fhj343"
}
]
},
{
"name": "Application data",
"id": "workspace://SpacesStore/3434gg-a761-48a2-83fa-3434f454hu",
"folders": [
{
"name": "Application letters",
"id": "workspace://SpacesStore/23232ff-c95f-4999-sdsd556-00886ggh7765"
}
]
}
]
}
这是我想要加载 JSON 数据的 Extjs 部分:
initComponent: function() {
// declare a new store and load tree data
this.store = new Ext.data.TreeStore({
// set params
proxy: {
type: 'ajax',
reader: 'json',
url: 'http://localhost:8080/testApp/rest/folder/1'
}
});
this.items = [{
flex: 1
}];
this.callParent();
}
最佳答案
您没有告诉读者要读取哪个属性:
reader: {
type: 'json',
rootProperty: 'folders'
}
关于javascript - Extjs 如何将 JSON 文件夹结构加载到树中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30374377/
我是一名优秀的程序员,十分优秀!