title: Extjs 4 Ext.data.Model: How to model nested objects
body: <p>I'm new to Extjs 4 and I'm trying to understand how to create a model for data that has nested objects.</p>
  
  <p>Example Data:</p>
  
  <pre><code>{
    data1:{
        field1:1,
        field2:2,
  
        **objField1**:{
            objField1:1,
            objField2:2,
  
            **anotherObj**:{
               field1:1,
               field2:2,
               arrayofObjs:[
                 {
                   //... 
                 },
                 //...
               ]
            }
        },
  
        objField2:{
            //... Some more fields or objects
        },
  
    data2:{
       //...
    }
  }
  </code></pre>
  
  <p>I'm trying to understand how I would model this data. The fields are easy</p>
  
  <pre><code>Ext.define('MyModel', {
  extend: 'Ext.data.Model',
  fields: [
      {name: 'field1',  type: 'int'},
      {name: 'field2',   type: 'int'}
  ], //...
  </code></pre>
  
  <p>But how do you model the objects? I was thinking I could create a model for the sub-objects and setup associations, but after reading the documentation, they seem to need to have IDs. So if you look at the belongsTo page, "The owner model is expected to have a foreign key which references the primary key of the associated model".</p>
  
  <p>I'm not looking to model data that has foreignkey relationships, just objects with sub-objects. So the server might return one JSON object with multiple sub-objects, and one of those objects I might want to tie to a grid, another object's data to a selectbox, etc.</p>
  
  <p>Thanks!</p>