【问题标题】:Add delete option to Kendo Grid向 Kendo Grid 添加删除选项
【发布时间】:2013-11-12 03:45:24
【问题描述】:

我有一个显示一些数据的 Kendo UI Grid。但现在我需要添加一个删除选项,因此也可以删除行。但这是如何工作的呢?

我在网格中添加了一个Destroy 方法。但这只是为了让它知道要调用什么Action

如何将每一行的删除图标添加到网格中?或者这通常在剑道网格中是如何工作的?

这是我目前的代码:

@(Html.Kendo().Grid<DescriptorWithResource>()
      .Name("grid")
      .PrefixUrlParameters(false)
      .Columns(columns =>
      {
          columns.Bound(x => x.Code).Title(Html.GetResource(KnownComponent, "ManagedDescriptorCode")).Width(250);
          columns.Bound(x => x.Description).Title(Html.GetResource(KnownComponent, "ManagedDescriptorDescription")).Width(500);
      })
      .Pageable(pager => pager.Info(true)
          .Refresh(false)
          .PageSizes(false)
          .PreviousNext(false)
          .Numeric(false)
          .Enabled(true)
          .Messages(m => m.Display(@Html.GetResource(KnownComponent, "Label_TotalRecordsResource"))))
      .Scrollable(scrollable => scrollable.Virtual(true))
      .Selectable(selectable => selectable.Enabled(false))
      .Events(e => e.DataBound("window.KendoExtensions.bindHoverEffect"))
      .DataSource(dataSource => dataSource
          .Ajax()
          .PageSize(50)
          .Events(e => e
              .RequestStart("window.Management.onDataSourceBinding")
              .Error("window.Management.onDataSourceError"))
          .Read(read => read.Action("ResultData", "Management"))
          .Destroy(destroy => destroy.Action("DeleteRow", "Management"))) // <-- Added
      )

【问题讨论】:

    标签: c# asp.net-mvc-4 kendo-ui kendo-grid


    【解决方案1】:

    您需要通过命令生成器声明它。

    columns => columns.Command(cmd=>cmd.Destroy())
    

    【讨论】:

      【解决方案2】:

      您可以为每一行的特定列添加一个 html 模板。在 html 模板中,您可以有一个用于删除的按钮或链接。单击此按钮/链接,您可以调用您的操作。

      template: '<input type="button" data-id=ID value="Delete" class="popupbutton" id="delButton" onclick="javascript:CheckAck(this);" id="Delete" /><br/>
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-12-15
        • 1970-01-01
        • 2016-01-23
        相关资源
        最近更新 更多