【问题标题】:How do I display a delete confirmation dialog before deleting a row in a DevExtreme DataGrid on a Razor page?如何在 Razor 页面上删除 DevExtreme DataGrid 中的行之前显示删除确认对话框?
【发布时间】:2021-08-02 01:29:28
【问题描述】:

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

我不确定如何/在客户端(cshtml 文件)中执行此操作。 我假设我会为此使用javascript/jquery? 是否存在我应该用于客户端对话框/消息框的第 3 方开源库?

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");
}

【问题讨论】:

    标签: asp.net-core razor datagrid devextreme


    【解决方案1】:

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

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

    【讨论】:

      猜你喜欢
      • 2017-07-21
      • 2020-12-12
      • 1970-01-01
      • 1970-01-01
      • 2016-02-06
      • 2017-08-22
      • 1970-01-01
      • 2014-02-16
      • 2017-12-20
      相关资源
      最近更新 更多