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

autocomplete index on change event.

4 Answers 444 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
Guillermo
Top achievements
Rank 1
Guillermo asked on 11 Sep 2012, 02:51 PM
Hello, 

I'm working with an autocomplete control with a datasource colection of objects with a "name" and "code" propertie. I'm displaying the name in the autocomplete.

I'm wondering how to get the Index of the item that i'm showing in the input in the change event to get the dataitem of that element without accessing to the datasource. Must be the change event, beacuse the select event is not what i need... because is fiered only when you select the element in the list and not when you type in the input.

Thanks a lot.
Guillermo Polit

4 Answers, 1 is accepted

Sort by
0
Guillermo
Top achievements
Rank 1
answered on 17 Sep 2012, 07:58 PM
I found a way:

//assign selected item
item = widget._current; (widget is the kendo element)
//check if item is selected or new
if (item != null) {
//set selected item index
index = item.index();
}
else {
//set index to -1, the item is new
index = -1;
}

But there is not documentation for: 
widget._current 

is there any other implementation for this?
0
Georgi Krustev
Telerik team
answered on 19 Sep 2012, 09:13 AM
Hi Guillermo,

 
I will suggest you check the "select" event. Here is shown how to get the dataItem from the dataSource - check the select event handler.

Greetings,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Guillermo
Top achievements
Rank 1
answered on 19 Sep 2012, 12:29 PM
the thing is that this is not triggered when you change the text of the input. only when you choose an element from the list. 

I need to get it when you change the text on input an there is one coincidence. That is why i choose the change event and not the select event...

any idea?

regards.
Guillermo
0
Georgi Krustev
Telerik team
answered on 20 Sep 2012, 08:20 AM
Hello Guillermo,

 
In that case, you can use your approach. Instead of _current use the current() method, which will return the same.

Kind regards,
Georgi Krustev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
AutoComplete
Asked by
Guillermo
Top achievements
Rank 1
Answers by
Guillermo
Top achievements
Rank 1
Georgi Krustev
Telerik team
Share this question
or