PDA

View Full Version : Combobox - fire select event



SurajSrinivasan
22 Feb 2010, 8:07 AM
I have created a combo-box and rendered it. I have also defined the 'select' listener:




var returnCombo = new Ext.form.ComboBox({
fieldLabel: comboLabel,
id: comboId,
name: comboId,
width:250,
typeAhead: true,
triggerAction: 'all',
editable: false,

lastQuery: '',
store: comboStore,

displayField: comboDisplay,

triggerAction: 'all',
emptyText:'Select ' + comboLabel,
valueNotFoundText: valNotFound,
selectOnFocus:true,
mode: 'local',
valueField: comboValue,
allowBlank:false

});





returnCombo.on('select', function fn (cb, rec, ind) {
... some logic ...
});


I want to select an item from the code. I used:


returnCombo.setValue(selectedVal);


However, this does not fire the select event. How do I fire it from the code. I know it can be done manually, but I have many combo boxes and need the default values to be set depending on some logic in the code.

SurajSrinivasan
22 Feb 2010, 9:00 AM
Found a way to override the setValue function.

http://www.extjs.com/forum/showthread.php?t=78726

BluemindSoftware
22 Jan 2014, 2:46 AM
I found it more efficient to use onChange instead of onSelect. That one is triggered when you set the value from code.