【问题标题】:Telerik MVC Grid Delete operationTelerik MVC 网格删除操作
【发布时间】:2011-09-06 05:44:38
【问题描述】:

我想问一下如何使用 ajax 绑定来拦截网格的 ajax 删除功能?具体来说,在我点击删除后,当弹出确认提示时,我想根据用户的选择做一些事情,

基本上,如果OK,就做这个,如果CANCEL做那个..

【问题讨论】:

    标签: asp.net-mvc-3 telerik telerik-grid telerik-mvc


    【解决方案1】:

    您需要使用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>
    

    【讨论】:

      【解决方案2】:

      demo page 似乎包含您正在寻找的示例。

      【讨论】:

      • 谢谢达林,我现在会调查的。
      猜你喜欢
      • 2012-07-24
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多