Results 1 to 3 of 3

Thread: List with merged store childs

  1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    8

    Default List with merged store childs

    Hello,

    Here is my data model :

    Code:
    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 :

    Code:
    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.

  2. #2
    Sencha User
    Join Date
    Aug 2011
    Posts
    8
    Answers
    1

    Default

    the code-example in the api-documentation do exatly what you want
    http://dev.sencha.com/deploy/touch/docs/?class=Ext.List

    alphabetic order:
    Code:
    ...
    
    getGroupString : function(record) {         
    return record.get('lastName')[0];     },
    
    ...
    Code:
    ...
    
    var list = new Ext.List({     
    fullscreen: true,          
    itemTpl : '{firstName} {lastName}',     
    grouped : true,     
    indexBar: true,          
    store: store // insert your store here }); 
    list.show();
    ...

  3. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    8

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •