View Full Version : Loading data from associations

11 Oct 2010, 12:41 PM
Hey all,

I wanted to know what was the correct way to load data from associations for a list.

For example I have an Employee model shown in a form panel and under that I have a tab with a to-many association for multiple addresses and would like to show these in an Ext.List.

What is the correct way of loading the addresses records into the list?

I know I can create an Ext.data.Store with the model "Address" but then I don't know how to set the relationship so that it only loads the addresses for the current employee.

I hope that makes sense.


10 Dec 2010, 1:14 PM
I should think you could just do a store.loadRecords(employee.get('addresses')).

10 Dec 2010, 6:09 PM
Ext.regModel('Employee', {
fields: ['id', 'name'],
hasMany: {model: 'Address', name: 'addresses'}

Ext.regModel('Address', {
fields: ['id', 'street', 'zip'],

proxy: {
type: 'rest',
url : '/addresses'

var someone = Ext.ModelMgr.create({id: 1, name: 'ed'}, 'Employee');

//returns a Store filtered to only the Addresses for the given Employese