如何向DropDownList添加自定义绑定

时间:2013-05-23 13:42:37

标签: kendo-ui

我有绑定的enterPress

// Custom keypress on ENTER event binding for input elements.
kendo.data.binders.enterPress = kendo.data.Binder.extend({
    init: function (element, bindings, options) {
        kendo.data.Binder.fn.init.call(this, element, bindings, options);
        var binding = this.bindings.enterPress;
        $(element).bind("keypress", function (e) {
            if (e.which == 13) {
                binding.get();
            }
        });
    },
    refresh: function () { }
});

如果我将它用于DropDownList我有错误:

  

未捕获错误:不支持enterPress绑定   DropDownList小部件

如何为DropDownList创建enterpress?

2 个答案:

答案 0 :(得分:1)

检查我对other问题的回复:

  

创建时应使用kendo.data.binders.widget命名空间   小部件绑定。为具有其角色的元素创建窗口小部件   数据属性集。

答案 1 :(得分:0)

You can capture the keydown event of all DropDownList controls using the following code:

kendo.ui.ComboBox.fn._keydown = function(e) {
    if (e.which == 13) {
        alert("key pressed!");
    }
};