autocomplete index on change event.

5 posts, 0 answers
  1. Guillermo
    Guillermo avatar
    8 posts
    Member since:
    Sep 2012

    Posted 11 Sep 2012 Link to this post

    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
  2. Guillermo
    Guillermo avatar
    8 posts
    Member since:
    Sep 2012

    Posted 17 Sep 2012 Link to this post

    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?
  3. Kendo UI is VS 2017 Ready
  4. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 19 Sep 2012 Link to this post

    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!
  5. Guillermo
    Guillermo avatar
    8 posts
    Member since:
    Sep 2012

    Posted 19 Sep 2012 Link to this post

    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
  6. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3706 posts

    Posted 20 Sep 2012 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready