Hi guys,
I am trying to add nested data to a store with a model with associations. So, I have:
User.js
Code:
Ext.define('Fiddle.model.User',{ extend: 'Ext.data.Model',
fields: [{
name: 'name',
type: 'string'
}]
});
Product.js
Code:
Ext.define('Fiddle.model.Product',{ extend: 'Ext.data.Model',
fields: [{
name: 'name',
type: 'string'
},{
name: 'user_id',
reference: 'User'
}]
});
and a store referencing the User model
Code:
Ext.define('Fiddle.store.Users', { extend: 'Ext.data.Store',
config: {
autoLoad: true,
model: 'Fiddle.model.User'
}
});
When I add nested data and try to obtain the information, I get an error:
Code:
var users = Ext.create('Fiddle.store.Users');users.add({
name: 'User1',
products:[{
name: 'product1'
},{
name: 'product2'
}]
});
users.getAt(0).products().getAt(0).get('name');
I note that the 'products' property is assigned directly to the model instance and it is not possible to get the store of products.
Can anyone help me with this? I appreciate any suggestion.
Here is the fiddle link: https://fiddle.sencha.com/fiddle/vti
Thanks