I have a kendo grid in a view in asp.net MVC application. When i press the delete button(Destroy function) in this kendo grid, a function is called in the controller to delete the object from the database. In the meantime i want to refresh the partial view where this grid is on, in order to refresh the labels in this view. Is it possible to add another jq function to the destroy button for example or is there other solution?

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

Here is the view code:

这是视图代码:

<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>

The script part: It calls a ajax request calling a method in the controller to view the partial view.

脚本部分:它调用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>

1 个解决方案

#1


0

Instead of this event mentioned in the question, this is added:

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

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

javascript function:

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

This avoid the infinite loop that took place before and only calls the partial page when the delete button is clicked. The data passed is the model that was previously passed to this partial page.

这样可以避免之前发生的无限循环,仅在单击删除按钮时调用部分页面。传递的数据是先前传递给此部分页面的模型。

更多相关文章

  1. 使用jQuery从一个.NET网格拖动并拖放到另一个gridview单元格
  2. 如何在HTML主体上设置网格ExtJS,高度为100%
  3. 儿童视图不在angular-ui-router中工作
  4. 如何定义两个日期之间的Kendo网格列过滤器?
  5. PHP选择具有特定宽度的图像并构建网格
  6. 可以将Eclipse配置为防止某些警告出现在Problems视图窗格中吗?
  7. 在Codeigniter中将javascript变量从视图发送到控制器[重复]
  8. 在php项目中, mysql视图常用吗?
  9. [CI]CodeIgniter视图 & 模型 & 控制器

随机推荐

  1. 突发!公信宝被查封一窝端,爬虫可能又惹祸了
  2. 推荐一些能能提高生产力的 Python 库
  3. Python 中更优雅的日志记录方案
  4. 这个 Python 库有必要好好学学
  5. Python一行代码搞定炫酷可视化,你需要了解
  6. 震惊了!每30秒学会一个Python小技巧,Github
  7. GitHub Actions,卧槽!牛批!
  8. 如何用 Python 给照片换色
  9. 原创丨我在 GitHub 上发现了哪些好的学习
  10. 还记得当年你是如何接触Python的吗?