PDA

View Full Version : Combobox Should have a option for don't fire the change Event when using setValue()



tanmayasahu
6 Dec 2013, 3:57 AM
Hi ExtJS Dev Team,
I am facing a issue with combobox setValue() method. My requirement is not to fire the change event of combobox, when I am setting the value using setValue(). Any way I have solved the problem by overriding the the setValue() method. But I think it is better to give a optional boolean parameter in the setValue() to use or avoid the change event.

Thanks...

scottmartin
6 Dec 2013, 10:13 AM
See if this will help:
http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.form.field.ComboBox-method-setRawValue

tanmayasahu
6 Dec 2013, 11:42 AM
Hi Scott,
SetRawValue() is for setting the displayValue, it will not change the value field of the combo am I right ?
I want the value of the combobox will get changed and the change event should not fire.

Thanks
Tanmaya

scottmartin
6 Dec 2013, 11:53 AM
Please see the following:



Ext.application({
name : 'Fiddle',

launch : function() {

var states = Ext.create('Ext.data.Store', {
fields: ['abbr', 'name'],
data : [
{"abbr":"AL", "name":"Alabama"},
{"abbr":"AK", "name":"Alaska"},
{"abbr":"AZ", "name":"Arizona"}
]
});

var combo = Ext.create('Ext.form.ComboBox', {
fieldLabel: 'Choose State',
store: states,
queryMode: 'local',
displayField: 'name',
valueField: 'abbr',
renderTo: Ext.getBody()
});

combo.on('change', function(combo){
console.log('--- change ---');
console.log(combo.getValue());
});

combo.setValue('AK');

setTimeout(function(){
console.log('--- set raw ---');
combo.setRawValue('AZ');
console.log(combo.getValue()); // value, but no change event
},1000);

}
});

tanmayasahu
7 Dec 2013, 12:03 AM
Hi Scott, Thanks for sharing the example, Actually I was passing the raw value to the setRawValue() method. That was my mistake.....