I have this format of 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"
}
]
there are multiple records, I have just included two records
This is my model and parsing code in sencha
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'},
]
}
});
parsing 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',
}
}
});
The problem I get only the last record from Json no matter how many records are there in the JSON.
and If I remove the id field (Notice the id fields in Json data) it works fine I can be able to have all records parsed.
Why it is doing so? How can I get all the records parsed with sencha?