1. #1
    Sencha User
    Join Date
    Jul 2009
    Location
    Austin, TX
    Posts
    47
    Vote Rating
    0
    slsmithtx is on a distinguished road

      0  

    Default Problem updating a combobox selection list with an ArrayStore

    Problem updating a combobox selection list with an ArrayStore


    So I have a combo box that uses an ArrayStore for its data. The combo definition looks like this:
    Code:
    {
         xtype: 'combo',
        store: store1,
        mode: 'local',
        id: obj.rolesCombinedSelectComboId,
        hidden:!obj.set_btn_add,
        typeAhead: false,
        forceSelection: true,
        //triggerAction: 'all',
        lastQuery: '',
        emptyText: 'Please select',
        width: 85,
        minListWidth: 200,
        //tpl: tpl,
        displayField: 'display_name',
        valueField: 'event',
        fieldLabel: 'Add New',
        tooltip: 'Select an item to create',
        editable: false
    }
    And I have the following code to update the store when certain events happen:

    Code:
    if (!Ext.isEmpty(obj.rolesCombinedSelectComboId)){
         var cmb = Ext.getCmp(obj.rolesCombinedSelectComboId);
         if (!Ext.isEmpty(cmb)){
             cmb.store.removeAll();
             var newData = [];
             var arraydata = obj.setRolesCombinedSelectionArray(obj);
             for (var ad=0;ad<arraydata.length;ad++){
                 var newRec = new cmb.store.recordType({
                     id: arraydata[ad][0],
                     display_name: arraydata[ad][1],
                     event: arraydata[ad][2],
                     description: arraydata[ad][3],
                     icon: arraydata[ad][4],
                     xtype: arraydata[ad][5]
                 });
                 newData.push(newRec);
             }
             cmb.store.add(newData);
             cmb.store.clearFilter();
        }
    }
    I got the above code from the following thread:
    http://www.sencha.com/forum/showthre...th-ArrayReader

    I can see that the store gets updated with the new values, but the combobox dropdown does not display the new data. Can anyone tell me what I'm doing wrong here?

    Also, I should mention, I"m using Ext 3.4

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,073
    Vote Rating
    854
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    This is working for me in 3.4.0:

    Code:
    var store = new Ext.data.ArrayStore({
        fields : [
            'event', 'display_name'
        ],
    
        data : [
            [1, 'One'],
            [2, 'Two'],
            [3, 'Three'],
            [4, 'Four'],
            [5, 'Five']
        ]
    });
    
    var form = new Ext.form.FormPanel({
        renderTo : Ext.getBody(),
        width    : 400,
        height   : 400,
        title    : 'Test',
        items    : [
            {
                xtype: 'combo',
                store: store,
                mode: 'local',
                typeAhead: false,
                forceSelection: true,
                //triggerAction: 'all',
                lastQuery: '',
                emptyText: 'Please select',
                width: 85,
                minListWidth: 200,
                //tpl: tpl,
                displayField: 'display_name',
                valueField: 'event',
                fieldLabel: 'Add New',
                tooltip: 'Select an item to create',
                editable: false
            }
        ]
    });
    
    setTimeout(function() {
        console.log('add data');
    
        var recs    = [],
            recType = store.recordType;
    
        recs.push(new recType({
            event        : 7,
            display_name : 'Seven'
        }));
    
        recs.push(new recType({
            event        : 8,
            display_name : 'Eight'
        }));
    
        store.add(recs);
    }, 2000);
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

Thread Participants: 1

Tags for this Thread