gpt4 book ai didi

带有代理的 extjs treestore

转载 作者:行者123 更新时间:2023-12-05 01:14:22 27 4
gpt4 key购买 nike

我正在创建一个 MVC extjs 应用程序。我有一个带有商店的树面板,它正在从 php 源加载数据。
我得到以下 json 格式的响应:

[
{
"text": "Home",
"leaf": true,
"dbName": "NULL",
"children": []
},
{
"text": "Moje Firma s.r.o.",
"leaf": false,
"expanded": false,
"children": [
{
"text": "Vydane",
"leaf": true,
"dbName": "demo"
},
{
"text": "Prijate",
"leaf": true,
"dbName": "demo"
}
]
},
{
"text": "Já Živnostník",
"leaf": false,
"expanded": false,
"children": [
{
"text": "Vydane",
"leaf": true,
"dbName": "demo_de"
},
{
"text": "Prijate",
"leaf": true,
"dbName": "demo_de"
}
]
},
{
"text": "Nezisková organizace",
"leaf": false,
"expanded": false,
"children": [
{
"text": "Vydane",
"leaf": true,
"dbName": "demo_neziskova"
},
{
"text": "Prijate",
"leaf": true,
"dbName": "demo_neziskova"
}
]
},
{
"text": "Příspěvková organizace",
"leaf": false,
"expanded": false,
"children": [
{
"text": "Vydane",
"leaf": true,
"dbName": "demo_prispevkovka"
},
{
"text": "Prijate",
"leaf": true,
"dbName": "demo_prispevkovka"
}
]
},
{
"text": "Moje Firma SK s.r.o.",
"leaf": false,
"expanded": false,
"children": [
{
"text": "Vydane",
"leaf": true,
"dbName": "demo_sk"
},
{
"text": "Prijate",
"leaf": true,
"dbName": "demo_sk"
}
]
}
]

我的店铺:
Ext.define('Statistics.store.Menu', {
extend: 'Ext.data.TreeStore',
model: 'Menu',
autoLoad: true,
autoSync: true,

proxy : {
type : 'ajax',
url : 'data.json',
reader: {
type: 'json'
}
}


});

和型号:
Ext.define('Statistics.model.Menu', {
extend: 'Ext.data.Model',

fields: [
{name: 'text', type: 'string'},
{name: 'leaf', type: 'boolean'},
{name: 'expanded', type: 'boolean', defaultValue: false},
{name: 'dbName', type: 'string', defaultValue: 'NULL'}
],

});

当数据保存在 .json 文件中时,此配置有效。但是当它们从 php 源加载时 id 不起作用。

感谢您的任何回答。

最佳答案

服务器响应必须如下所示:

{
success: true,
children: // here is the array of items
}

关于带有代理的 extjs treestore,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13952140/

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