1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    183
    Vote Rating
    0
    Answers
    5
    pinidbest has a little shameless behaviour in the past

      0  

    Default Answered: combo adding items

    Answered: combo adding items


    How do I add items to a combofield dynamicly?
    I cant find any sample that does not invlove a store.

    If this the case how do I create an empty store and add model instance to it so that the combo will show these items?

  2. You can use a simple array store and populate the array as needed
    use store.loadData(data) to populate the store

    Code:
    var data = [
            {"abbr":"AL", "name":"Alabama"},
            {"abbr":"AK", "name":"Alaska"},
            {"abbr":"AZ", "name":"Arizona"}
        ];
    
    
    // The data store containing the list of states
    var states = Ext.create('Ext.data.Store', {
        fields: ['abbr', 'name'],
        data : [ ]
    });
    
    // Create the combo box, attached to the states data store
    Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: states,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody()
    });
    
    states.loadData(data);
    Regards,
    Scott.

  3. #2
    Sencha - Support Team scottmartin's Avatar
    Join Date
    Jul 2010
    Location
    Houston, Tx
    Posts
    9,197
    Vote Rating
    482
    Answers
    690
    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

      0  

    Default


    You can use a simple array store and populate the array as needed
    use store.loadData(data) to populate the store

    Code:
    var data = [
            {"abbr":"AL", "name":"Alabama"},
            {"abbr":"AK", "name":"Alaska"},
            {"abbr":"AZ", "name":"Arizona"}
        ];
    
    
    // The data store containing the list of states
    var states = Ext.create('Ext.data.Store', {
        fields: ['abbr', 'name'],
        data : [ ]
    });
    
    // Create the combo box, attached to the states data store
    Ext.create('Ext.form.ComboBox', {
        fieldLabel: 'Choose State',
        store: states,
        queryMode: 'local',
        displayField: 'name',
        valueField: 'abbr',
        renderTo: Ext.getBody()
    });
    
    states.loadData(data);
    Regards,
    Scott.

  4. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    183
    Vote Rating
    0
    Answers
    5
    pinidbest has a little shameless behaviour in the past

      0  

    Default thanks

    thanks


    thanks

Thread Participants: 1