This is a migrated thread and some comments may be shown as answers.

Turn a list item into a token with JS?

2 Answers 33 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Yan Moura asked on 25 Jun 2020, 03:26 PM

I need to manually select the first list matching item and turn it into a token.

 

Reading the documentation I think that the way to go would be within the example below:

var autoComplete = $find("<%= RadAutoCompleteBox1.ClientID %>");
var newEntry = autoComplete.createEntry('Text', 'Value');
var entries = autoComplete.get_entries();
entries.add(newEntry);

 

 

However instead to create newEntry manually I need to capture the first item in the list that matches user typing (text and value). Any idea?

 

Thanks!

2 Answers, 1 is accepted

Sort by
0
Accepted
Peter Milchev
Telerik team
answered on 30 Jun 2020, 09:01 AM

Hello Yan Moura,

As the AutoCompleteBox is created to handle large set of data, the items in the dropdown are not persisted unless the client-side filtering is used. 

With that said, most of the times the items are not in the dropdown after it closes, hence you cannot access them unless the dropdown is visible. 

If you want to create an entry from the first match automatically on blur, I recommend setting HighlightFirstMatch="true". That would highlight the first match automatically and will create an entry out of it once the control loses focus. 

Regards,
Peter Milchev
Progress Telerik

Progress is here for your business, like always. Read more about the measures we are taking to ensure business continuity and help fight the COVID-19 pandemic.
Our thoughts here at Progress are with those affected by the outbreak.
0
Yan Moura
Top achievements
Rank 1
Veteran
Iron
answered on 01 Jul 2020, 06:26 PM
Thank you Peter!
Tags
AutoCompleteBox
Asked by
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Answers by
Peter Milchev
Telerik team
Yan Moura
Top achievements
Rank 1
Veteran
Iron
Share this question
or