PDA

View Full Version : JsonStore not getting data from JSON when there is no array nesting



sissonb
24 Feb 2011, 3:46 PM
I currently have this JSON,

[{
"header":{
"billing":{},
"equipment":[],
"serviceAddress":{
"lastName":"TESTONE",
"countyName":"ROCKWALL",
"zipcode":"75202182400",
"state":"TX",
"streetNumber":"700",
"streetName":"ROSS AVE",
"firstName":"MOVERS",
"country":"USA",
"city":"DALLAS"
}
},
"blah":{

}
}]
hooked up to this JsonStore,


SummaryData = Ext.extend(Ext.data.JsonStore, {
constructor: function(cfg) {
cfg = cfg || {};
SummaryData.superclass.constructor.call(this, Ext.apply({
storeId: 'SummaryData',
url: 'http://localhost/testData/quickAccess.json',
autoLoad: true,
baseParams:{accountId:"22494335"},
method:'POST',
fields: [
{
name: 'firstName',
mapping: 'header.serviceAddress.firstName'
},
{
name: 'lastName',
mapping: 'header.serviceAddress.lastName'

},
{
name: 'city',
mapping: 'header.serviceAddress.city'
},
{
name: 'state',
mapping: 'header.serviceAddress.state'
},
{
name: 'streetName',
mapping: 'header.serviceAddress.streetName'

},
{
name: 'streetNumber',
mapping: 'header.serviceAddress.streetNumber'
},
{
name: 'zipCode',
mapping: 'header.serviceAddress.zipcode'
}
]
}, cfg));
}
});
new SummaryData();


I don't want the JSON to be nested inside an array, but when I remove it from the array, the JsonStore no longer recognizes the JSON . How would I get the above JsonStore to work with the below JSON?


{
"header":{
"billing":{},
"equipment":[],
"serviceAddress":{
"lastName":"TESTONE",
"countyName":"ROCKWALL",
"zipcode":"75202182400",
"state":"TX",
"streetNumber":"700",
"streetName":"ROSS AVE",
"firstName":"MOVERS",
"country":"USA",
"city":"DALLAS"
}
},
"blah":{

}
}

Thanks!

sissonb
24 Feb 2011, 4:36 PM
I have fixed it. I added, idProperty: 'header', and it did the trick!

makiss
18 Apr 2011, 12:40 PM
hey mate, same issue thanks for posting... can you elaborate how and where idProperty did the trick?