Soham Shah
Soham Shah

Reputation: 571

Dynamically setting multiSelect for combobox in extJS

I am kinda facing an interesting problem with my combobox's multiSelect property.

I have a grid with three columns ID, Name, Associated Part.

I have enabled Rowediting plugin and editors for ID is textfield(EditID), Name is textfield(EditName) and Associated Part is combobox(EditPartCombo with multiSelect true).

I have two buttons Add and Update.

When I select any row in the grid and press Update, rowediting starts at that exact position. In the Update button code, i am setting the multiselect property of EditPartCombo to false but somehow it is not reflecting.

Code on Update button:

{
text: 'Update Press',

handler: function(btn){

var grid = btn.up('grid');
var selection = grid.getSelectionModel().getSelection();


if(selection.length > 0){

combo = Ext.getCmp('EditPartCombo');
combo.multiSelect = false;
delete combo.picker;
combo.createPicker();
combo.reset();

var rowEditing = grid.getPlugin('RowEditPlugin');
var rowno = grid.store.indexOf(selection[0]);
rowEditing.cancelEdit();

rowEditing.startEdit(rowno, 1);  
}

else{ Ext.Msg.alert('Error' , 'Please Select a row to Update'); } 

}

In firebug when I inspect combo - it shows that multiSelect as false but still i am able to select multiple values.

Not sure what am I doing wrong?

Please help.

Thanks in advance.

Upvotes: 0

Views: 2445

Answers (1)

Lorenz Meyer
Lorenz Meyer

Reputation: 19895

If you cange a config value after a component is created, it is not guaranteed that this value is applied. For some config option, it is and for other it doesn't work.

I would recommend you to Ext.create the combobox, and inject this multiSelect configuration at that time. Like this for one button you create it with multiSelect enabled, and disabled for the other.

Upvotes: 1

Related Questions