How to pick first value from dropdown list in AutoCompleteBox?

0 Answers 96 Views
AutoCompleteBox DropDownList
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Yan Moura asked on 27 May 2021, 04:57 PM | edited on 27 May 2021, 06:23 PM

Hi!

I am using AutoCompleteBox and I would like to know how to get the very first value of the dropdown list (client side) with Javascript.

Thanks!

 

EDIT: I figured how to do this using the event dropDownItemDataBound in case someone else needs it:

        

var typed = ""; var current = ""; function requesting(sender, eventArgs) { var acbox = $find('<%= RadAutoCompleteBox1.ClientID %>'); var acboxcontents = acbox.get_inputElement(); typed = acboxcontents.value; } function dropDownItemDataBound(sender, args) { if (current != typed) { if (typed.substr(typed.length-1, 1) == " ") { var acbox = $find("<%= RadAutoCompleteBox1.ClientID %>"); var newEntry = acbox.createEntry(args.get_item().get_text(), args.get_item().get_text()); var entries = acbox.get_entries(); entries.add(newEntry); current = typed; typed = "";
} } }

Right after the client types a blank space (for instances "mysearch ") the code above gets the first value of the dropdown list, converts it into a token, ignores all the rest of the values in the list and clear up the typed string.

Now I just need to know how to set focus back to AutoCompleteBox... Telerik controls are like puzzles and everything is so hard to achieve. :(

No answers yet. Maybe you can help?

Tags
AutoCompleteBox DropDownList
Asked by
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Share this question
or