title: Sencha Touch: How to get data from complex JSON objects
body: <p>I am not able retrieve records from complex json objects but i am able to get the data when using an TPL.</p>
  
  <p>Please see the below example codes:</p>
  
  <p><strong>JSON:</strong></p>
  
  <pre><code>{
  "lists": [
      {
          "title": "Groceries",
          "id": "1",
          "items": [
              {
                  "text": "contact solution - COUPON",
                  "listId": "1",
                  "id": "4",
                  "leaf": "true" 
              },
              {
                  "text": "Falafel (bulk)",
                  "listId": "1",
                  "id": "161",
                  "leaf": "true" 
              },
              {
                  "text": "brita filters",
                  "listId": "1",
                  "id": "166",
                  "leaf": "false" 
              }
          ] 
      } 
  ]
  </code></pre>
  
  <p><strong>Model:</strong></p>
  
  <pre><code>Ext.regModel("TopModel", 
  {
      fields: [
          { name: 'title', type: 'string' },
          { name: 'id', type: 'string' },
      ],
      hasMany: [
          { model: 'SubModel', name: 'items' }
      ],
      proxy: {
      type: 'ajax',
      url : 'test/lists.json',
          actionMethods: {
              create: 'POST',
              destroy: 'POST',
              read: 'POST',
              update: 'POST'
      },
      reader: {
          type: 'json',
          root: function(data) {
                      return data.lists || [];
                  }
      }
     }
  });
  
  Ext.regModel("SubModel", 
  {
      fields: [
              { name: 'text', type: 'string'},
          { name: 'listId', type: 'string'},
          { name: 'id', type: 'string'},
          { name: 'leaf', type: 'string'}
      ]
  });
  </code></pre>
  
  <p><em><strong>In my View file, i have defined the store as below.</em></strong></p>
  
  <pre><code>this.stores = new Ext.data.Store({
              clearOnPageLoad: false,
          autoLoad:true,
              model:'TopModel',
          getGroupString: function(record) {
          return record.get('leaf');
              }
  });
  });
  </code></pre>
  
  <p>I am not able to retrieve the values for <em>record.get('leaf')</em> as this refers to the child model items. When I tried to print it, it prints as undefined.</p>
  
  <p>How to access the child attributes? Here 'items' is listed as an array. </p>
  
  <p>I tried to display the data using list as below. All the records are displayed but the problem is that it is picked as one whole item instead of separate list for each item.</p>
  
  <pre><code>var list = new Ext.List({
      cls: 'big-list',
      grouped : true,
      emptyText: '&lt;div&gt;No data found&lt;/div&gt;',
      itemTpl: ['&lt;div&gt;&lt;tpl for="items"&gt;',
          '&lt;div&gt;',
          '{id} {text}',
          '&lt;/div&gt;',
          '&lt;/tpl&gt;&lt;/div&gt;',
          ],
      store: this.stores,
      listeners: {
          itemtap: this.onListItemTap,
          scope: this
      }
  });
  </code></pre>
  
  <p>Kindly help me on how to get the list items to be displayed as individual records.</p>