ExtJs 4 Data associations -


i'm having hard time getting want out of ext. i'm trying divide restful response nested parameters. 1 of parameters array of objects, each object has few more parameters. how can build model/store/view recognize type of response?

response = {   stuffineed: {     animals,     fruits,     veggies = {       cucumbers,       apples,       pears,       squash = {         winter,         pumpkin,         summer = {           yellow,           green         }       }     }   },    stuffidontneed: {     ...   },    morestuffidontneed: {     ...   } } 

how use associations build model/store? lets assume 'base' model looks this:

ext.define('myapp.model.stuffineed', {     extend: 'ext.data.model',     fields: [       {name: 'animals', type: 'boolean'},       {name: 'fruits', type: 'boolean'},       {name: 'veggies', type: 'array'}     ],      hasmany: [{name: 'veggies', model: 'veggiemodel'}],      proxy: {       type: 'rest',       url: '/someserver'       reader: {         root: 'data',         totalproperty: 'totalcount'       }     }   } 

do need second veggie model mirrors parameters i'm looking for? how inject array of veggie models root?

ext.define('myapp.model.veggie', {   extend: 'ext.data.model',   fields: [     {name: 'cucumbers'},     {name: 'apples'},     {name: 'pears'},     {name: 'squash', type: 'array'}      belongsto: 'myapp.model.stuffineed'   ] }); 

one option, if don't need full integrity of model system, use type: 'auto', keeps data raw data returned. model.get('veggies') give object can access normal javascript object.


Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -