在Razor页面上删除DevExtreme DataGrid中的行之前,如何显示删除确认对话框



我在Asp.NetCore web应用程序中使用DevExtreme和razor页面。我想在删除行时插入客户端删除确认对话框。目前,我正在控制器上使用asp操作来进行删除调用。

我不确定在客户端(cshtml文件(中如何/在哪里执行此操作。我想我会以某种方式使用javascript/jquery来实现这一点吗?是否存在我应该用于客户端对话框/消息框的第三方开源库?

cshtml文件中的DevExtreme DataGrid定义

@(Html.DevExtreme().DataGrid<Customer>()
.DataSource(Model)
.Columns(columns => {
columns.AddFor(m => m.CustomerName);
columns.AddFor(m => m.CustomerId).CellTemplate(
<form asp-action="DeleteCustomer" method="post">
<input type="hidden" value="<%- data.CustomerId %>" name="CustomerId" />
<input type="image" src="/icon/close.png" />
</form>
</text>).Caption("");
});

服务器端控制操作代码:

[HttpPost]
public async Task<IActionResult> DeleteCustomer(Guid customerId)
{
// Call WebApi Service to delete row
return RedirectToAction("Index");
}

我相信数据网格有一个内置的功能,用于在客户端确认删除操作。可能不是你想要的,但这可能是一个好的开始。

以下是演示页面的链接:https://demos.devexpress.com/ASPNetCore/Demo/DataGrid/RowEditingAndEditingEvents/

最新更新