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

Autocomplete with "suggest: true" how to get associated dataItem id when user types and hits enter

1 Answer 24 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Kerry
Top achievements
Rank 1
Kerry asked on 16 Aug 2013, 10:28 PM
I am using autocomplete with "suggest: true".  My autocomplete data source is a json array with name and id.  The "name" is used as the dataTextField.  I need to get the associated id with the name that is chosen.  When using "suggest: true" the user can type part of the name and have a selection item appear in the autocomplete box hit enter and never actually select an item from the list.  When this happens how can I get the id associated with the name?

I am able to get the id when the user selects is from the list.

I have a jsFiddle with this code at:
http://jsfiddle.net/KerryJenkinsDTC/a6cdb/7/




1 Answer, 1 is accepted

Sort by
0
Accepted
Kiril Nikolov
Telerik team
answered on 19 Aug 2013, 06:56 AM
Hello Kerry,

I could achieve this by binding to the close event, and searching the widgets dataSource for the value entered, and then get it's id via the DataItem selected. To make it easier to understand I have prepared a short example using your code and displaying the ID of the selected element on the following jsBin:

http://jsbin.com/AriwobO/1/edit
 
Regards,
Kiril Nikolov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
AutoComplete
Asked by
Kerry
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
Share this question
or