How to work with the bound data

10 posts, 1 answers
  1. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 05 Oct 2011 Link to this post

    Ok, so I have the autocomplet bound to an oData datasource.  When I select one of the items in the list, I want to callback to the service with the key for that item to populate a template on my page

    How do I go about doing that? :)
  2. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 11 Oct 2011 Link to this post

    Hello Steve,

     
    The autocomplete widget does not persist selected item. Hence it will be very hard to understand which item is selected and get its relevant data item. I will suggest you use the ComboBox widget.

    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!
  3. Kendo UI is VS 2017 Ready
  4. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 11 Oct 2011 Link to this post

    Naw...I like the autocomplete, it's what I need :)  It's a google-like search filter...so it's more of a single select...however I can't guarantee the resulting text will be unique.

    If there was an event in which I could store that value myself, I'd love to take advantage of it...I dont need the autocomplete to do that FOR me...but I do want that object once the item is selected somehow.

    PLEEEASE? :)

    Steve
  5. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 12 Oct 2011 Link to this post

    Any news on a decision?

    I could care less if you guys store the values of the JSON object...but at least provide ME an event to be able to do that if I so choose....otherwise you're just throwing valid already queried data away making me re-query to get it back.
  6. Answer
    Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 14 Oct 2011 Link to this post

    Hello Steve,

     
    In order to achieve your goal you will need to wire the client event of the popup element and retrieve the clicked data item. Check this jsFiddle example.

    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!
  7. Steve
    Steve avatar
    1851 posts
    Member since:
    Dec 2008

    Posted 14 Oct 2011 Link to this post

    Oh good thanks...while I am disapointed that it won't be part of the control, i appreciate the simple sample :)
  8. Igor
    Igor avatar
    18 posts
    Member since:
    Oct 2011

    Posted 16 Oct 2011 Link to this post

    Hi Georgi,

    this is great but it's only working on "click" event. I can't bind it on "keypress". Is it possible to make it work when user is using keyboard to select item from popup?
  9. Georgi Krustev
    Admin
    Georgi Krustev avatar
    3707 posts

    Posted 17 Oct 2011 Link to this post

    Hello Igor,

     
    As I said the autocomplete is not build to persist selected index. Even I have provide a way how to get the selected item on key action, the approach will not work when multiple values are allowed. 
    I will suggest you examine this jsFiddle example which shows how to modify the combobox UI widget to look like the autocomplete.

    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!
  10. Seven Spikes
    Seven Spikes avatar
    6 posts
    Member since:
    Oct 2009

    Posted 23 Feb 2012 Link to this post

    Hi guys,

    We also wanted to get the currently selected item in the drop down and to use the information in it.
    Here is the code that works for us:
    change: function (e) {
                        var selected = $(".k-list").find(".k-state-selected");
        // get the data in the selected element and use it as you wish
    }

    We rely on the class .k-state-selected being set on the item that has been selected.
    Basically on the change event you get the selected element that has been clicked when the user uses its mouse or the element on which the user has pressed the enter button. So it works in both cases. 

    It is not the perfect solution but it works and might be useful to someone.
    Note that the Change event can be raised not only when an item in the drop down is selected.
    It is also raised when the value of the input element is changed i.e some other js methods changing its value.

    Hope this helps!
  11. James
    James avatar
    2 posts
    Member since:
    Jul 2012

    Posted 25 Jul 2012 Link to this post

    If using the ComboBox instead of the auto-complete is there a way to hide the drop down button?
Back to Top
Kendo UI is VS 2017 Ready