gpt4 book ai didi

javascript - Extjs 如何将 JSON 文件夹结构加载到树中?

转载 作者:行者123 更新时间:2023-11-28 00:17:02 25 4
gpt4 key购买 nike

我正在尝试使用 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com