• If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Announcement

Collapse
No announcement yet.

Combobox multiSelect value problem

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Combobox multiSelect value problem

    Hello,

    I have a multiselect combobox that I'm trying to set the values for. The multiselect creates a string separated by commas. How can I use this string to set the values in the combobox when I do an edit? I would have thought that architect would take the multiselect setting into account and set the values, but no. More explanation below.

    Here is the code for a regular combobox. The value correctly sets the setValue for the dropdown.
    Code:
    {
                                xtype: 'combobox',
                                itemId: 'MTROOTCAS',
                                fieldLabel: 'Stop Cause',
                                name: 'MTROOTCAS',
                                value: 'MTROOTCAS',
                                size: 50,
                                editable: false,
                                displayField: 'RCCAUSE',
                                store: 'StopCause',
                                valueField: 'RCCAUSE'
                            },
    Here's the code for a multiselect combobox. No values get set for this. Any help or direction is appreciated.
    Code:
    {
                                xtype: 'combobox',
                                itemId: 'CSFIL1LIN1',
                                fieldLabel: 'Container Codes - Top Line 1',
                                name: 'CSFIL1LIN1',
                                value: 'CSFIL1LIN1',
                                size: 90,
                                editable: false,
                                displayField: 'ALPHA3',
                                forceSelection: true,
                                multiSelect: true,
                                store: 'Coder',
                                valueField: 'ALPHA1'
                            },
    Last edited by JosephHarriman; 08-19-2016, 07:44 AM.

  • #2
    You can pass the value as an array of values since it's a multi-select combo. Example below of defaulting the combo to have two values selected and setting the value of the combo with two values after it has been rendered via a button.

    Code:
    // The data store containing the list of states
    var states = Ext.create('Ext.data.Store', {
        fields : ['abbr', 'name'],
        data   : [
            {"abbr" : "AL", "name" : "Alabama"},
            {"abbr" : "AK", "name" : "Alaska"},
            {"abbr" : "AZ", "name" : "Arizona"}
            //...
        ]
    });
    
    Ext.create('Ext.panel.Panel', {
        height   : 300,
        width    : 300,
        renderTo : Ext.getBody(),
        bbar     : [{
            text    : 'Set States',
            handler : function () {
                var combo        = Ext.ComponentQuery.query('combo')[0],
                    firstTwoRecs = lastTwoRecs = [states.getAt(0), states.getAt(1)];
    
                //set the value of the combo to the first two records in the states store
                //
                combo.setValue(firstTwoRecs);
            }
        }],
        items    : [{
            xtype        : 'combo',
            fieldLabel   : 'Choose State',
            store        : states,
            queryMode    : 'local',
            displayField : 'name',
            multiSelect  : true,
            valueField   : 'abbr',
            value        : ['AL', 'AK']
        }]
    });

    Comment

    Working...
    X