D'Arcy Rail-Ip
D'Arcy Rail-Ip

Reputation: 11975

How to programmatically select more than one value in Ext JS Combobox?

In my code:

    // Here we get the nodes for each job and select them from the combo box.
    var nodesArrayForJobID = this.getNodesForJobID(jobID);
    for (var i = 0; i < nodesArrayForJobID.length; i++) {
        var node = nodesArrayForJobID[i];
        Ext.getCmp(jobID + "combobox_nodes").select(node)
    }

It knows to select more than one value (runs through for loop twice), but selecting a new value deselects the old one.

How can I select more than one value at once? I'm looking for either a command that selects multiple nodes (takes in an array), or a command that has a parameter to specifically not deselect existing selected nodes.

Thanks.

Upvotes: 1

Views: 4232

Answers (3)

Manuel Roldan
Manuel Roldan

Reputation: 535

You can use the MultiCombo component:

<ext:MultiCombo ID="multiCombo1" SelectionMode="All" runat="server" Mode="Local"
    DisplayField="Text" ValueField="Value" StoreID="storeMultiCombo"
    EmptyText="Select a value" Editable="false" AllowBlank="false" CausesValidation="true"
    meta:resourceKey="multiCombo1" ></MultiCombo>

Upvotes: 0

newmount
newmount

Reputation: 1951

You could use value:[ArrayOfValues] config or use setValue([ArrayOfValues]) method to select more than one value

Sample fiddle here: https://fiddle.sencha.com/#fiddle/9u8

Upvotes: 2

pherris
pherris

Reputation: 17743

Did you configure your combo box to allow multi-select?

http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.field.ComboBox-cfg-multiSelect

Upvotes: 2

Related Questions