2

我如何在按钮单击(btnSelect)时获得剑道自动完成的选定值

$(document).ready(function () {
    $("#titles").kendoAutoComplete({ 
        minLength: 3, 
        dataTextField: "SDesc", 
        dataValueField: "RefID", 
        template: '${ data.SDesc } ' + '(' + '${ data.SDate }' + ')',

        dataSource: {
            type: "odata",
            serverFiltering: true,
            serverPaging: true,
            pageSize: 20,
            transport: {
                read: "http://localhost:54329/HH_WcfDataService.svc/Product"
            }
        }
    });   

    $('#btnSelect').click(function (e){
        var onSelect = function(e) {
            // access the selected item via e.item (jQuery object)
        };

        // attach select event handler via bind()
        $("#titles").data("kendoAutoComplete").bind("select", onSelect);

        // detach select event handler via unbind()
        $("#titles").data("kendoAutoComplete").unbind("select", onSelect);
  });
});
4

1 回答 1

2

使用 AutoComplete 的value方法来获取它的值。

   $('#btnSelect').click(function (e){
        var value = $("#titles").data("kendoAutoComplete").value();

        // Use the `value`
   });
于 2012-11-23T07:53:46.573 回答