1

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?

4

1 に答える 1

0

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.c​​om/documentation/api/web/autocomplete#select

http://demos.kendoui.c​​om/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番目のリンクのように、アイテムのインデックスを取得できるようになりました

于 2012-12-13T08:38:05.243 に答える