I have a Kendo AutoComplete control.
It fetches data from the remote json source.
The returned array looks a little like this...
It fetches data from the remote json source.
The returned array looks a little like this...
[{"id":"50344","name":"Jane Doe"},{"id":"50562","name":"John Doe"}]
It is just a list of user names, and their user ids.
I want to grab the "id" field from this data when one of the users are selected from the dropdown list.
Is that possible?
http://www.easyiguanacare.info/taking_care_of_a_pet_iguana.html
if i add forms for providing information about personal details for e-commerce site?
Kindly analyse me site and please provide me the valid answer.
thanks in advance.
functiononSelect(e) {if("kendoConsole"inwindow) {vardataItem =this.dataItem(e.item.index());kendoConsole.log("event :: select ("+ dataItem +")");}}doesn't actually work. e.item doesn't exist. I have a template - when I select an item, my event fires. But accessing the "e.item" parameter fails.
How do I get access to this object?
Actually, I'm kind of surprised that it doesn't just pass the selected object as a parameter to the event - it seems like this is a pretty common requirement (and based on the # of views of this thread, it's probably safe to say it is).
EDIT: Apparently I was binding to the wrong event. I was binding to Change instead of Select.
@(Html.Kendo().AutoComplete().Name("countries").Filter("startswith").Placeholder("Select country...").BindTo(new string[] {"Jane Doe","John Doe"}).Separator(", ").Events(e => e.Select("selectCountry")))<script>function selectCountry(e) {// get data itemvar dataItem = this.dataItem(e.item.index());// throw it in the console (F12)kendo.logToConsole("event :: select (" + dataItem + ")");}</script>You can find such example here. I would also recommend checking this article, which describes how to install the KendoUI for JSP demos locally.
Kind regards,
Alexander Popov
the Telerik team
The change event is triggered when an actual change in the values occurs. This could happen either when the user selects an item or when the value is changed programmatically through the API. Once the change event is triggered you can try to get the dataItem, if there is one matching the current value.
Regards,
Alexander Popov
Telerik
Hi Alexander,
Is it possible to get values of multiple values selected??
I tried
function onSelect(e) {
var dataItem = this.dataItem(e.item.index());
console.log("event :: select (" + dataItem + ")" );
}
But I'm able to get the value of the one I've selected. Can you please provide an example on how to get value of multiple elements, if there is a coma separator in the kendoAutoComplete??
The Autocomplete's value method returns a string, so getting the separate items is not supported. In that case it might be better to use the MultiSelect widget instead.
Regards,
Alexander Popov
Telerik
Hi Alexander,
I changed to MultiSelect. But I'm not able to access the selected data as an array.
var stackdata = [
{text: "Android", value: 1},
{text: "JavaScript", value: 2},
{text: "iOS", value: 3},
{text: "Java", value: 4},
{text: "Hadoop", value: 5},
{text: "R", value: 6},
{text: "Power BI", value: 7},
{text: "Spark", value: 8},
{text: "Tableau", value: 9},
{text: "J2EE", value: 10},
{text: "ATG", value: 11},
{text: "Kendo UI", value: 12}
];
$(".stack").kendoMultiSelect({
dataSource: stackdata,
dataTextField: "text",
dataValueField: "value",
filter: "startswith",
placeholder: "Select stack...",
separator: ", ",
select: onSelect,
// dataBound: onDataBound
});
$(".done").click(function(){
var required = $(".stack").data("kendoMultiSelect");
console.log(required.text);
});
I am not getting the array of selected elements. (Also, my select tag uses a class{It is being used in other pages as well(Not the exact same thing, I should be able to select different stacks in different pages, and different values selected is to be returned on clicking an icon with class name "done")})
Can you please tell me how to access this as one single array comprising the text values(not the id number..).
Thanks.
This can be done by setting the MultiSelect's dataValueField option to "text" as well, then call the value method. In case the value field should remain as-is, then you can use the dataItems method and manually construct the text array, as illustrated here.
Regards,
Alexander Popov
Telerik