我试图在网格中使用cancel事件,但该事件从未被激发。
代码:
$("#grid").kendoGrid({
editable: true,
toolbar: ["create", "save", "cancel"],
dataSource: _dataSource,
columns: [{
title: "Description",
field: "description"
}, {
title: "Active",
field: "active"
}],
edit: function (e) {
console.log("add row");
},
cancel: function (e) {
console.log("cancel row");
}
});
当我点击"添加新记录"时,控制台显示"添加行",但当我点击"取消更改"时,控制台中不会显示任何内容。
这是一个非常简单的代码,它遵循文档,但我是否遗漏了什么?
版本:Kendo UI v2016.1.112
谢谢!
如果你想intercept
工具栏版本,这个演示应该会有所帮助:
http://dojo.telerik.com/omOhU
我所做的就是将以下事件附加到工具栏的取消按钮上:
$(".k-grid-cancel-changes").on('click', function(e){
e.preventDefault();
console.log("intercepted on cancel change event");
return true;
});
这将阻止默认的单击操作,先执行一些操作。在这种情况下,将日志记录到控制台,然后返回true以继续操作。
我还添加了编辑命令,向您显示当在编辑模式下单击取消按钮时,会触发事件。
希望这能有所帮助。任何问题都会让我大吃一惊。