Note that there are some explanatory texts on larger screens.

plurals
  1. POSencha Touch - access 1 to 1 model relationship
    primarykey
    data
    text
    <p>I'm trying to access the following JSON from my model store. I have no problem accessing the root (Name and Address) but i can't access anything in Financials (NetWorth or Income). I've verified the JSON below is being returned from the server.</p> <p>I know this has to be super easy but every example I've seen is showing how to access a 1 to many relationship. My model is a 1 to 1. Person->Financials. Right now I don't have any associations setup as I don't know how to setup a 1 to 1 relationship. I've tried associations, I've tried belongsTo, I've tried Financials.NetWorth from inside my itemTPL. Nothing.</p> <p>Can someone please show me the light? </p> <p><strong>JSON returned from server</strong></p> <pre><code>[{ "PersonName": "John Smith", "Address": "123 main street", "Financials": [{ "NetWorth": "$500,000", "Income":"$67,000" }] }] </code></pre> <p><strong>I registered my Models.</strong> </p> <pre><code>Ext.regModel('Person', { fields: [ {name: 'Name', type:'string'}, {name: 'Address', type: 'string'}, ], }); Ext.regModel('Financials',{ fields: [ {name: 'NetWorth', type:'string'}, {name: 'Income', type: 'string'}, ], }); </code></pre> <p><strong>And registered the store</strong></p> <pre><code>var commStore = new Ext.data.Store({ model: 'Person', proxy: { type: 'ajax', url : 'Business/GetData', reader: { type: 'json', } }, autoLoad:false, }); </code></pre> <p><strong>and displaying back in a list</strong></p> <pre><code>var commList = new Ext.List({ fullscreen: false, itemTpl : '&lt;div&gt;{PersonName}&lt;/div&gt;&lt;div&gt;{Business.NetWorth}&lt;/div&gt;', store: commStore, height:500, width:"100%", }); </code></pre> <p>Any help would be much appreciated. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload