1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    90
    Answers
    2
    Vote Rating
    2
    darkhorni is on a distinguished road

      0  

    Default Answered: How do I apply a store to a combobox?

    Answered: How do I apply a store to a combobox?


    Code:
    {
        fieldLabel: 'Tip',
        name: 'SubjectType',
        allowBlank: false,
        xtype: 'combo',
        displayField: 'name',
        valueField: 'type',
        typeAhead: true,
        forceSelection: true,
        queryMode: 'local',
        store: subjectTypeStore,
        listeners: {
            select: function(a,selected,c){
                //console.log(a);
                var tets = selected[0].data.type;
                console.log(tets);
                //console.log(c);
            }
        }
    },
    {
        name: 'SubjectID',
        allowblank: false,
        xtype: 'combo',
        displayField: 'name',
        valuefield: 'name',
        typeAhead: true,
        forceSelection: true,
        queryMode: 'local'
    }
    What I want to do is to apply a combobox store to the second combobox according to the selected item in the first combobox. For example if you select Pokemons then the second combobox should load pokemonStore. You change your mind and you select Smurfs, then the second combobox loads the smurfsStore.

    What I want to learn is how to apply the store to an existent combobox.

  2. See if this will work for you:

    Code:
    var statesA = Ext.create('Ext.data.Store', {
        fields: ['abbr', 'name'],
        data : [
            {"abbr":"AL", "name":"Alabama"},
            {"abbr":"AK", "name":"Alaska"},
            {"abbr":"AZ", "name":"Arizona"}
        ]
    });
    
    var statesZ = Ext.create('Ext.data.Store', {
        fields: ['abbr', 'name'],
        data : [
            {"abbr":"ZL", "name":"ZAlabama"},
            {"abbr":"ZK", "name":"ZAlaska"},
            {"abbr":"ZZ", "name":"ZArizona"}
        ]
    });
    
    var comboA = Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: statesA,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody(),
        listeners: {
            select: function(combo) {
                comboZ.bindStore(statesZ);
            }
        }
    });
    
    var comboZ = Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: null,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody()
    });
    Scott.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    8,998
    Answers
    665
    Vote Rating
    456
    scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future scottmartin has a brilliant future

      1  

    Default


    See if this will work for you:

    Code:
    var statesA = Ext.create('Ext.data.Store', {
        fields: ['abbr', 'name'],
        data : [
            {"abbr":"AL", "name":"Alabama"},
            {"abbr":"AK", "name":"Alaska"},
            {"abbr":"AZ", "name":"Arizona"}
        ]
    });
    
    var statesZ = Ext.create('Ext.data.Store', {
        fields: ['abbr', 'name'],
        data : [
            {"abbr":"ZL", "name":"ZAlabama"},
            {"abbr":"ZK", "name":"ZAlaska"},
            {"abbr":"ZZ", "name":"ZArizona"}
        ]
    });
    
    var comboA = Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: statesA,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody(),
        listeners: {
            select: function(combo) {
                comboZ.bindStore(statesZ);
            }
        }
    });
    
    var comboZ = Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: null,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody()
    });
    Scott.

Thread Participants: 1

Tags for this Thread