我使用Sencha Touch 1.1構建酒吧定位器。我使用CakePHP作爲我的後端API,我希望能夠使用Cake輸出它的數據。在使用CakePHP後端的Sencha Touch商店中嵌套的JSON對象API
查看下面的JSON數據,您會看到Pub數據以類似的方式返回到「Pub」數組和郊區。所以訪問數據將進行如下:
Pub.id, Pub.name, Pub.address_1
有誰知道我可以在我的煎茶模型和存儲使用這種格式?
我有我的模型和存儲設置如下:
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
});
下面是從我的店裏代理返回JSON數據。
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"}}]});