Using KendoAutoComplete control and binding values from the database.
Then when I try to retrieve the value here I'm getting the selected text.
Can anyone advice me how to get the Id of the selected item?
Select
ドロップダウン リストの項目を選択し、オートコンプリートのテキストを設定するイベントを使用できます。
// get a reference to the autocomplete widget
var autocomplete = $("autocomplete").data("kendoAutoComplete");
// selects by jQuery object
autocomplete.select(autocomplete.ul.children().eq(0));
http://docs.kendoui.com/documentation/api/web/autocomplete#select
http://demos.kendoui.com/web/autocomplete/events.html
編集:select
イベントを処理してみてください
$("#products").kendoAutoComplete({
dataSource: data,
select: onSelect
});
それから :
function onSelect(e) {
if ("kendoConsole" in window) {
var dataItem = this.dataItem(e.item.index());
kendoConsole.log("event :: select (" + dataItem + ")" );
}
}
2番目のリンクのように、アイテムのインデックスを取得できるようになりました