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

How to work with the bound data

9 Answers 245 Views
AutoComplete
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 06 Oct 2011, 02:49 AM
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? :)

9 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 11 Oct 2011, 12:00 PM
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!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 11 Oct 2011, 03:24 PM
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
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 12 Oct 2011, 06:18 PM
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.
0
Accepted
Georgi Krustev
Telerik team
answered on 14 Oct 2011, 07:41 AM
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!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 14 Oct 2011, 04:40 PM
Oh good thanks...while I am disapointed that it won't be part of the control, i appreciate the simple sample :)
0
Igor
Top achievements
Rank 1
answered on 16 Oct 2011, 06:34 PM
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?
0
Georgi Krustev
Telerik team
answered on 17 Oct 2011, 02:03 PM
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!
0
Seven Spikes
Top achievements
Rank 1
answered on 23 Feb 2012, 08:35 PM
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!
0
James
Top achievements
Rank 1
answered on 25 Jul 2012, 07:06 PM
If using the ComboBox instead of the auto-complete is there a way to hide the drop down button?
Tags
AutoComplete
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Georgi Krustev
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Igor
Top achievements
Rank 1
Seven Spikes
Top achievements
Rank 1
James
Top achievements
Rank 1
Share this question
or