我想在网格中删除按钮的点击事件完成时执行一个 Action 。我怎么知道什么时候在 Javascript 中点击了?
最佳答案
(阅读最后的重要)
使用:
$("tr .k-grid-delete", "#grid").on("click", function(e) {
alert("deleted pressed!");
})
#grid
是您的网格的 ID。
如果你想知道你可以做的数据项:
var item = $("#grid").data("kendoGrid").dataItem($(this).closest("tr"));
或者,您可以将 grid.columns
中的 command
定义为:
{
command: [
"edit",
{
name : "destroy",
text : "remove",
click: myFunction
}
],
title : "Commands",
width : "210px"
}
myFunction
是:
function myFunction(e) {
alert("deleted pressed!");
var item = $("#grid").data("kendoGrid").dataItem($(this).closest("tr"));
// item contains the item corresponding to clicked row
}
重要提示:您可能想要定义您自己的 destroy
按钮,其中仅从原始样式复制样式(没有其他操作/检查)。如果是这样,请将您的 grid.columns.command
定义为:
{
command: [
"edit",
{
name : "destroy",
text : "remove",
className: "ob-delete"
}
],
title : " ",
width : "210px"
}
然后定义:
$(document).on("click", "#grid tbody tr .ob-delete", function (e) {
e.preventDefault();
alert("deleted pressed!");
var item = $("#grid").data("kendoGrid").dataItem($(this).closest("tr"));
// item contains the item corresponding to clicked row
...
// If I want to remove the row...
$("#grid").data("kendoGrid").removeRow($(this).closest("tr"));
});
关于javascript - 单击完成后如何在剑道 ui 网格中捕获销毁事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14524600/