Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Stan on Mar 24, 2008 12:40
open dhtmlx forum
How to select an option in dhtmlxCombo without trigerring onChage event?

Hi,

I have a combo box with onChane event attached:

categoryCombo.attachEvent("onChange", doOnCategoryChange);

This let's me do some custom processing when user selects a value from combo box.


I want to be able to programmatically select an option and not trigger the onChange event.
However, doing the following:

categoryCombo.selectOption(idx);

triggers the onChange event as well. Is there a way not to trigger onChange for programmatic option selection?

Thank you,
Stan.
Answer posted on Mar 25, 2008 03:24
By default, the selectOption method calls "onChange" event.  This call can be disabled  by the third parameter of the selectOption method (the second one enables autocomplit range):

combo.selectOption(idx,false,false);

Please beware that such call will change only text of combo, not actually selected value


Answer posted by Support on Mar 25, 2008 03:21
There is no way to call selectOption without firing onChange event, but you can use current combo value and text by

     grid.setComboValue(value);
     grid.setComboText(text);

those methods just change related property without triggering any events.
Answer posted by Stan on Mar 25, 2008 08:24

This solution works partialy

     grid.setComboValue(value);
     grid.setComboText(text);

because it does not select the proper option in the combo.  That is if user clicks on combo the old option is still selected.

Stan.