0
我的JSON格式解析JSON与煎茶
[
{
"docid": "1",
"doc_title": "Dato' Dr.",
"doc_name": "xyz",
"doc_code": "001",
"doc_category": "3",
"doc_subcategory": "",
"id": "0"
},
{
"docid": "1",
"doc_title": "Dr.",
"doc_name": "ABC",
"doc_code": "002",
"doc_category": "4",
"doc_subcategory": "",
"id": "0"
}
]
有多个记录,我刚才包括两个记录
这是我在煎茶模型和解析代码
Ext.define('User', {
extend: 'Ext.data.Model',
config: {
fields: [
{name: 'docid', type: 'string'},
{name: 'doc_title', type: 'string'},
{name: 'doc_name', type: 'string'},
{name: 'doc_code', type: 'string'},
{name: 'doc_category', type: 'string'},
{name: 'doc_subcategory', type: 'string'},
{name: 'id', type: 'string'},
]
}
});
解析JSON
var store = Ext.create('Ext.data.Store',
{
autoLoad: true,
model: "User",
listeners:
{
beforeload: function (store,operation,eOpts)
{
}
},
proxy: {
type: 'ajax',
url : 'http://someurl/doctor/search',
reader: {
type: 'json',
rootProperty: 'users',
}
}
});
无论JSON中有多少条记录,我都只能从Json获取最后一条记录。
,如果我删除id
场(注意:在JSON数据ID字段),它工作得很好,我可以能够有分析所有记录。
为什么这样做?我如何获得所有用sencha解析的记录?
做的下面的答案解决你的问题。如果是,那么接受它,否则告诉我们什么没有工作,你得到了什么错误。 –