So, I have a parent and child repository shown here:
Parent model
Ext.define('APP.model.Client', { extend: 'Ext.data.Model', requires: [ 'APP.model.Website', 'Ext.data.association.HasMany', 'Ext.data.association.BelongsTo'], fields: [{ name: 'id', type: 'string' }, { name: 'name', type: 'string' }, { name: 'slug', type: 'string' }, { name: 'active', type: 'boolean' }, { name: 'current', type: 'boolean' }], hasMany: { model: 'APP.model.Website', name: 'websites' } });
Baby model
Ext.define('APP.model.Website', { extend: 'Ext.data.Model', fields: [{ name: 'id', type: 'string' }, { name: 'client_id', type: 'string' }, { name: 'sub_domain', type: 'string' }, { name: 'active', type: 'boolean' }], belongsTo: 'APP.model.Client' });
Using an AJAX call through the server, I load the Clients
repository and it loads normally. But the Websites
store does not fill up, and when I stop at the Clients
store on.load function to see what it fills, the Client
store is filled only with client data, but in raw
for this store, I can see all the Websites
data. This way it returns correctly, but my extjs are incorrect. Here are the shops:
Customer shop
Ext.define('APP.store.Clients', { extend: 'Ext.data.Store', autoLoad: false, model: 'APP.model.Client', proxy: { type: 'ajax', url: '/client/list', reader: { type: 'json', root: 'items' } }, sorters: [{ property: 'name', direction: 'ASC' }] });
Website repository
Ext.define('APP.store.Websites', { extend: 'Ext.data.Store', requires: ['Ext.ux.Msg'], autoLoad: false, model: 'APP.model.Website', proxy: { type: 'ajax', url: '/client/list', reader: { type: 'json', root: 'items' }, writer: { type: 'json' } }, sorters: [{ property: 'sub_domain', direction: 'ASC' }] });
My end result ... I would like to fill both stores so that I can click on the item, and when it loads something from the parent store, I can access the child store (there will be more when I find out this problem) to fill a couple of grid tabs.
What am I missing in my setup? I just downloaded extjs4 a couple of days ago, so I'm on 4.1.