Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Steve Schreiner on Oct 01, 2008 07:18
open dhtmlx forum
select text in combobox when opened

When opening a type ahead combobox, how can I get the text in the text area of the combobox to be selected? When its a type ahead box, the options in the dropdown only show that match whats in the text area of the dropdown (sinces its in type ahead mode), but this can be confusing for people as it appears there is only one option available. The user can start backspacing and then see more options, but I would like to select the text initially...
Answer posted by Support on Oct 01, 2008 08:12
Something similar to next must work

Just text preselection
combo.attachEvent("onOpen",function(){
     var text=combo.getComboText();
     dhtmlXRange(this.DOMelem_input,0,text.length);
});

Preselection with showing full list of options
combo.attachEvent("onOpen",function(){
     var text=combo.getComboText();
     combo.setComboText("");
     combo.filterSelf();//show all options
     combo.setComboText(text);//restore old text
     dhtmlXRange(this.DOMelem_input,0,text.length);
});
Answer posted by Steve Schreiner on Oct 01, 2008 08:25
I tried this:

combo.attachEvent("onOpen",function(){
     var text=combo.getComboText();
     dhtmlXRange(this.DOMelem_input,0,text.length);
});

and when I double click my grid cell, the combobox text is selected, but then the dropdown list appears and then the combos text selection becomes unselected.  Seems like a timing issue?  For some reason the opening of the drop list with the options seems to unselect the text selection...
Answer posted by Support on Oct 01, 2008 08:49
If you are using combo in auto-loading mode without inner cache, then, each time when combo opened - it will send request to the server side , for list of options, after loading of which list of options and current selection will be reset. 

You can try to add the same logic to one more event - onSelectionChange - in such case it will not lost selection after xml loading.