Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 8th, 2012  |  syntax: None  |  size: 1.38 KB  |  hits: 20  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Nested JSON objects in Sencha Touch store using CakePHP backend API
  2. Pub.id, Pub.name, Pub.address_1
  3.        
  4. Ext.regModel('Pub', {
  5.     fields: ['id', 'name', 'address_1', 'address_2', 'marker', 'lat', 'lng', 'suburb']
  6. });
  7.  
  8. Ext.regStore('NearbyStore', {
  9.     model: 'Pub',
  10.     sorters: 'suburb',
  11.     getGroupString: function(record) {
  12.         return record.get('suburb');
  13.     },
  14.     proxy: {
  15.         type: 'scripttag',
  16.         url: 'http://exampleurl/bars/nearby.json?lat=-55.8874&lng=-11.177',
  17.         reader: {
  18.             type: 'json',
  19.             root: 'results'
  20.         }
  21.     },
  22.     autoLoad: true
  23. });
  24.        
  25. 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"}}]});
  26.        
  27. Ext.regModel('Pub', {
  28. fields: [
  29. {  
  30.     name: 'id',
  31.     type: 'string',
  32.     mapping: 'Pub.id'
  33. },
  34. {
  35.     name: 'name'
  36.     type: 'string',
  37.     mapping: 'Pub.name'
  38. },
  39. {
  40.     name: 'address_1',
  41.     type: 'string',
  42.     mapping: 'Pub.address_1'
  43. },
  44. {
  45.     name: 'AND SO ON.......'
  46. }
  47. });