如何使用 ExtJS JSONReader 读取不可迭代参数
我发送以下 JSON 结构:
{ "header": "Staff Name",
"result":[
{"firstname":"Leo","id":1,"lastname":"name"},
{"firstname":"Robert","id":2,"lastname":"name"}],
"totalCount":4,
"success":true}
在我的 JS 文件中,我定义 JSONReader 如下:
var resultReader = new Ext.data.JsonReader({
root:'result',
totalProperty: 'totalCount'
}, Ext.data.Record.create([
{name: 'id'} ,
{name: 'firstname'},
{name: 'lastname'}
]));
这有效,我能够迭代结果数组。然而,我想要实现的是能够以某种方式读取在结构开头找到的参数“header”。
我应该如何定义 JSONReader 来存储这个参数,以及以后如何加载这个参数?
I am sending over the following JSON structure:
{ "header": "Staff Name",
"result":[
{"firstname":"Leo","id":1,"lastname":"name"},
{"firstname":"Robert","id":2,"lastname":"name"}],
"totalCount":4,
"success":true}
In my JS file I define the JSONReader as follows:
var resultReader = new Ext.data.JsonReader({
root:'result',
totalProperty: 'totalCount'
}, Ext.data.Record.create([
{name: 'id'} ,
{name: 'firstname'},
{name: 'lastname'}
]));
This works and I am able to iterate over the result-array. However what I want to achieve is to somehow be able to read the parameter "header" found in the beginning of the structure.
How should I define the JSONReader to store this parameter, and how can I later load this parameter?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该可以在
resultReader.jsonData.header
处找到It should be available at
resultReader.jsonData.header