我已经使用Kendo指令启动了Kendo Grid。如何捕获网格的keydown / keypress事件?我的最终目标是根据另一列的用户输入来填充网格列。例如,输入名字时填写电话号码。为此,除非有更好的方法,否则我必须使用Kendo Grid编辑和按键事件并在用户输入上进行搜索。这可能吗?
这就是我初始化网格的方式:
<section id="dashboard-view" class="mainbar" data-ng-controller="dashboard as vm">
....
<div kendo-grid="vm.testGrid" k-options="vm.testGridOptions" k-rebind="vm.testGridDataSource.data" k-on-edit="vm.onEdit(kendoEvent)"></div>
....
</section>
我的JavaScript文件中定义的选项:
vm.testGridOptions = {
columns: [
{ field: "Id", title: "ID" },
{ field: "FirstName", title: "First Name" },
{ field: "LastName", title: "Last Name" },
{ field: "Phone", title: "Phone" },
{ command: ["destroy"] }
],
toolbar: ["create", "save", "cancel"],
dataSource: vm.testGridDataSource,
editable: {
createAt: "bottom"
},
height: 400,
autoBind: false
};
vm.onEdit = function (e) {
//if grid column == Id && keypressed == Tab key
//search
};
网格处于批处理编辑模式。
由于Kendo Grid对此没有本地事件,因此我使用了JQuery onBlur事件。
vm.onEdit = function (e) {
alert("Edit event fired");
$('input.k-input.k-textbox').blur(function (f) {
alert("Blur event fired");
}
};
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句