如何为 ExtJS 存储创建多个根 JSON?
我想在服务器端创建一个具有 2 个根的 JSON 字符串。我正在使用 ExtJS 3.2。我想使用第一个根将数据加载到网格,第二个根是用不同的数据填充表单。 我正在服务器端创建 JSON 字符串,如下所示;
{
metaData: {
"idProperty": "reportID",
"root": "data",
"successProperty": "success"
},
"success": true,
"data": [
{
"ID": 1,
"name": "Jon",
"surname": "Doe"
}]
}
我们假设第二个根名称是summary,第二个idProperty是summaryID。我该如何实现这一点以及在哪里添加摘要数据? 谢谢大家。
I want to create a JSON string on server side with 2 root. I am using ExtJS 3.2. I want to use first root for load data to grid and the second one is to fill a form with different data.
I am creating JSON string on server side like this;
{
metaData: {
"idProperty": "reportID",
"root": "data",
"successProperty": "success"
},
"success": true,
"data": [
{
"ID": 1,
"name": "Jon",
"surname": "Doe"
}]
}
Let's assume second root name is summary and second idProperty is summaryID. How can I implement this and where can I add summary data?
Thx all.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
没有你愿意做的自动魔法。我在这个项目上遇到了同样的问题,我发现了如何从 JSON 响应自动创建多个商店。在加载网格之前放置以下代码。在 extjs4 中,我将以下代码放入 app.js 中,以便在初始化应用程序时创建商店。将创建商店自动的、依赖的关于 JSON 返回的内容:
为您的案例创建的商店将是
MA.store.root1
和MA.store.root2
其中 MA 是您的应用程序命名空间(您应该更改它无论您的应用程序命名空间是什么)。此代码适用于 extjs4,您可能需要一些修改才能使其在旧版本中工作。希望它有所帮助。There is no automagic for you are willing to do.i had the same issue on this project and i figured out how to create multiple stores automatically from a JSON response.put the following code before your grids are loaded.in extjs4,i put the following code in app.js so the stores will be created when the app is initialized.The stores will be created automatically,dependent on what the JSON returns:
Created stores for your case would be
MA.store.root1
andMA.store.root2
which MA is your apps namespace(and you should change it to whatever your app namespace is).This code is for extjs4 and you might need some modifications to make it work in older versions.Hope it helps.