I am using Sencha Touch 1.1 to build a bar locator. I am using CakePHP as my backend API and I want to be able to use the data as Cake outputs it.
Viewing the JSON data below you will see that the Pub data is returned in the 'Pub' array and the Suburb in a similar way. So accessing the data would be done as follows:
Pub.id, Pub.name, Pub.address_1
Does anyone know how I can use this format in my Sencha model and store?
I have my model and store setup as follows:
Ext.regModel('Pub', {
fields: ['id', 'name', 'address_1', 'address_2', 'marker', 'lat', 'lng', 'suburb']
});
Ext.regStore('NearbyStore', {
model: 'Pub',
sorters: 'suburb',
getGroupString: function(record) {
return record.get('suburb');
},
proxy: {
type: 'scripttag',
url: 'http://exampleurl/bars/nearby.json?lat=-55.8874&lng=-11.177',
reader: {
type: 'json',
root: 'results'
}
},
autoLoad: true
});
Below is the JSON data that is returned from my store proxy.
stcCallback1001({"results":[{"Pub":{"id":"125","name":"Brownsville Bowling & Recreation Club","address_1":"31a malouffst","address_2":"-","marker":"default_marker.png","lat":"-33.887402","lng":"151.177002"},"Suburb":{"name":"Knoxville"},"0":{"distance":"0.0002511751890598611"}},{"Pub":{"id":"1721","name":"Hampshire Hotel","address_1":"91 parramatta rd","address_2":"-","marker":"default_marker.png","lat":"-33.886799","lng":"151.177002"},"Suburb":{"name":"Brownsville"},"0":{"distance":"0.06684402352323478"}}]});