PDA

View Full Version : data store and associations



Jad
24 Feb 2012, 12:48 AM
Hello

How can I specifies a multi column association

Example

I have employees, companies and emails

Employees and companies have mane emails

So I want to make a model like this




Ext.define('contact', {
extend: 'Ext.data.Model',
fields: [ 'id', 'name' ],
proxy: { ... }
},
hasMany: [{ model: 'email', name: 'emails', relation: 'email.typeReferrer=1 and email.idReferrer=contact.id' }]
});

Ext.define('companie', {
extend: 'Ext.data.Model',
fields: [ 'id', 'name' ],
proxy: { ... }
},
hasMany: [{ model: 'email', name: 'emails', relation: 'email.typeReferrer=2 and email.idReferrer=companie.id' }]
});

Ext.define('email', {
extend: 'Ext.data.Model',
fields: [ 'id', 'email', 'typeReferrer', 'idReferrer' ],
proxy: { ... }
}
});




Thank you for your help :-)

mitchellsimoens
24 Feb 2012, 12:24 PM
You should use the associations config instead of hasMany and you can have multiple hasMany associations in that array.