PDA

View Full Version : List with merged store childs



chaaarly
30 Aug 2011, 1:00 AM
Hello,

Here is my data model :


app.models.Agency = Ext.regModel('Agency', {
fields: [
{ name: 'id' },
{ name: 'name' },
{ name: 'address' },
{ name: 'city' },
{ name: 'zipCode' },
{ name: 'country' }],

associations: [{
type: 'hasMany',
model: 'AgencyManager',
name:'managers'
}]
});

one2one.models.AgencyManager = Ext.regModel('AgencyManager', {
fields: [
{ name: 'id' },
{ name: 'lastName' },
{ name: 'firstName' },
{ name: 'agency_id' },
{ name: 'type' },
{ name: 'color' },
],

associations: [{
type: 'belongsTo',
model: 'Agency',
name: 'agency' , primaryKey: 'id', foreignKey: 'agency_id'
}]
});

and my store :


app.stores.AgencyStore = new Ext.data.JsonStore({
storeId: 'agencyStore',
model: 'Agency',
sorters: 'name',
autoLoad : true,

proxy: {
type: 'rest',
url : '/Agency',
reader: {
type: 'json'
}
}
});

With that, i'am able to load all my agencies and my managers in my store. Now i would like to display a liste with all the managers of all agencies in the alphabetic order. How can i do that ?

Thanks in advance.

arkos
30 Aug 2011, 11:55 PM
the code-example in the api-documentation do exatly what you want ;)
http://dev.sencha.com/deploy/touch/docs/?class=Ext.List

alphabetic order:


...

getGroupString : function(record) {
return record.get('lastName')[0]; },

...




...

var list = new Ext.List({
fullscreen: true,
itemTpl : '{firstName} {lastName}',
grouped : true,
indexBar: true,
store: store // insert your store here });
list.show();
...

chaaarly
31 Aug 2011, 12:09 AM
Not exactly...

My store main objects are Agencies which contain Managers.

If I specify my Agencies store as store of my list, the list will iterate on Agencies but not on Managers in Agencies. What I want is that each item of my list correspond to each Managers of all Agencies.