Dear:
In the sample from :
http://ift.tt/1pqhOms
In the sample from :
http://ift.tt/1pqhOms
I have changed the code to fellow Associate sample。
But,how to add 2 User's data ,and product's data,then make sure I have filter by User.name='Ed'
Code:
<script type="text/jscript">
Ext.require(['Ext.grid.*', 'Ext.data.*' ]);
var uersX;
var productsX;
var store;
Ext.onReady(function(){
Ext.define('Product', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'user_id', type: 'int'},
{name: 'name', type: 'string'}
],
proxy: {type: 'ajax',
url: 'users'
},
autoLoad: true
});
Ext.define('User', {
extend: 'Ext.data.Model',
fields: [
{name: 'id', type: 'int'},
{name: 'name', type: 'string'}
],
hasMany: {model:'Product'
,name: 'products'
,filterProperty: 'name'}
});
userX = Ext.ModelManager.create({id: 1, name: 'Ed'}, 'User');
productsX = userX.products();
productsX.add({ name: 'Another Product'});
productsX.add({ name: 'Another Product2'});
productsX.sync();
store = new User({query: 'name'}).products();
})
</script>
Aucun commentaire:
Enregistrer un commentaire