在 kendo 网格中使用删除按钮后,如何刷新 MVC 中的部分视图

How to refresh the Partial View of in MVC, after using the delete button in a kendo grid

我在 asp.net MVC 应用程序的视图中有一个 kendo 网格。当我在此 kendo 网格中按下删除按钮(销毁函数)时,控制器中会调用一个函数来从数据库中删除该对象。同时我想刷新这个网格所在的局部视图,以便刷新这个视图中的标签。是否可以向销毁按钮添加另一个 jq 函数,或者是否有其他解决方案?

查看代码如下:

<div id="Browsegrid">

 @(Html.Kendo().Grid<WEB02.ConfigurationModel.TestGrid>()
.Name("grid")
.Columns(columns =>
{

    columns.Bound(o => o.Name).Width(110);
    columns.Bound(o => o.Type).Width(130);
    columns.Command(command => command.Destroy()).Width(110);

     })
.Sortable()
.Scrollable(scrollable => scrollable.Virtual(true))
.HtmlAttributes(new { style = "height:430px;" })
.DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(p => p.Name))
    .Events(events =>
                          {
                                events.RequestEnd("onRequestEnd"); 
                          })
    .PageSize(100)
    .Read(read => read.Action("TestGrid", "Configuration"))
            .Destroy("TestDelete", "Configuration")    
    )
    .Pageable(pageable => pageable
        .Refresh(true))
)

</div>

脚本部分:它调用一个ajax请求调用控制器中的一个方法来查看局部视图。

<script>

function onRequestEnd(e) {

    $.ajax({

        url: '/Configuration/_WorkflowPartial',
        contentType: 'application/html charset=utf-8',
        type: 'GET',
        dataType: 'html',
        data: { 'nodeName': NN, 'nodeType': NT, 'nodeID': NI, 'nodeURL': NU },
        success: function (data) {
            $('#body').html(data);
        }
    })
}

</script>

不是问题中提到的这个事件,而是添加:

.Events(events => events.Error("error_handler").Sync("sync_handler"))

javascript函数:

function sync_handler(e) {
    $.ajax({

        url: '/Configuration/_WorkflowPartial',
        contentType: 'application/html charset=utf-8',
        type: 'GET',
        dataType: 'html',
        data: { 'nodeName': NN, 'nodeType': NT, 'nodeID': NI, 'nodeURL': NU },
        success: function (data) {
            $('#body').html(data);
        }
    })
}

这样就避免了之前发生的无限循环,只在点击删除按钮时才调用部分页面。传递的数据是之前传递给这个部分页面的模型。