我想问一下如何使用ajax绑定拦截网格的ajax删除功能?具体来说,直到点击删除后,当弹出确认提示时,我想根据用户的选择做一些事情,
基本上,如果确定,请执行此操作,如果CANCEL这样做..
答案 0 :(得分:2)
您需要使用OnRowDataBound并将点击处理程序附加到删除按钮。然后,您可以显示自定义确认并决定要执行的操作。如果你想'防止网格删除代码 - 请调用e.stopPropagation()。这是一个快速示例:
<%: Html.Telerik().Grid(Model)
// Prevent the grid from displaying the default delete confirmation
.Editable(editing => editing.DisplayDeleteConfirmation(false))
// Subscribe to the OnRowDataBound event
.ClientEvents(e => e.OnRowDataBound("onRowDataBound"))
%>
<script>
function onRowDataBound(e) {
$(e.row) // get the current table row (TR) as a jQuery object
.find(".t-grid-delete") // find the delete button in that row
.click(function(e) { // handle its "click" event
if (confirm("Do you want to delete this record?")) {
// User clicked "OK"
} else {
// User clicked "Cancel"
e.stopPropagation(); // prevent the grid deletion code from executing.
}
});
}
</script>
答案 1 :(得分:1)
demo page似乎包含了您要查找的内容的示例。