单击按钮时,kendo自动完成选择值

时间:2012-11-23 05:52:07

标签: asp.net-mvc-3 javascript-events kendo-ui

如何在按钮单击(btn Select)

上获得kendo自动填充选定值
$(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);
  });
});

1 个答案:

答案 0 :(得分:2)

使用自动完成功能的value方法获取其值。

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

        // Use the `value`
   });