PDA

View Full Version : How to clear current value in a editable combo box when trying to key in a new value.



varmaj80
17 Jun 2014, 10:24 AM
Hello All,

I am using extJs 4.2. I have an editable combo box where the values in the combo box are fetched from a data store. Say, I selected a value from the dropdown by typing in a value. Now, if I want to key in a new value in the field, I move the mouse to the first position in the field and start typing. But the old value in the field is still present there and is getting appended to the new value. Also if I click on the dropdown button, the control automatically goes to the first position in the field and when I start typing in something , the existing value gets appended to the new value. How do I clear out the existing value in the dropdown when I start keying in a new value. How do I make sure that once I start keying in a value in the field's first postion, the existing value will get cleared. Is there any property to set this or do I need to write a handler for this?..

I can reproduce this issue in the following Sencha examples page

http://dev.sencha.com/extjs/5.0.0/examples/kitchensink/#form-combos

Thanks,

varmaj80
17 Jun 2014, 2:15 PM
I can remove the old value by highlighting it and delete the value or with backspace. However I don't want to use those extra clicks. The value should automatically disappear once I start typing a new value.

Gary Schlosberg
18 Jun 2014, 9:49 AM
Perhaps the selectOnFocus config can do what you need:
http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.field.ComboBox-cfg-selectOnFocus

varmaj80
18 Jun 2014, 11:00 AM
Thanks a lot Gary. selectOnFocus resolved my issue. Thank you.