Results 1 to 2 of 2

Thread: Problem updating a combobox selection list with an ArrayStore

  1. #1
    Sencha User
    Join Date
    Jul 2009
    Location
    Austin, TX
    Posts
    47
    Vote Rating
    0
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,551
    Vote Rating
    1271
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it! Checkout the CODE tag!

    Check out my GitHub, lots of nice things for Ext JS and Sencha Touch
    https://github.com/mitchellsimoens

Tags for this Thread

Posting Permissions

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