Kendo UI Grid Toolbar - 将dataItem传递给DestroyButton / EditButton

时间:2015-03-18 10:16:03

标签: razor kendo-grid

我有一个带有工具栏(Razor语法)的Kendo UI网格,我无法弄清楚要将什么作为参数传递到DestroyButton / EditButton。我知道按钮需要" dataItem" - 但我怎么做到的?

这是我的网格:

@(Html.Kendo().Grid<AspNetPermission>().Name("grid")
      .DataSource(ds => ds.Ajax().Read(read => read.Action("Permissions_Read", "AspNetPermissions"))
          .Model(model => model.Id(p => p.Id))
          .Create(create => create.Action("Create", "AspNetPermissions").Data("sendAntiForgery"))
          .Update(update => update.Action("Edit", "AspNetPermissions").Data("sendAntiForgery"))
          .Destroy(destroy => destroy.Action("Delete", "AspNetPermissions").Data("sendAntiForgery"))
      )
      .Columns(columns =>
      {
          columns.Bound(permission => permission.Name).Width(300);
      })
      .Selectable(selectable => selectable
      .Mode(GridSelectionMode.Single)
      .Type(GridSelectionType.Row))
      .Sortable()
      .Pageable()
      .Editable(edit => edit.Enabled(true))
      .ToolBar(tb => tb.Template(
          @<text>
               @*display buttons only if user is enabled*@
               @if (ViewBag.CanUserManage == true)
               {
                   @item.CreateButton("Add", new{@class="SPAdd"})
                   @item.EditButton(whatToPutHere) <!--    This is where I have a problem -->
                   @item.DestroyButton(whatToPutHere)  <!--    This is where I have a problem -->
                   @item.SaveButton("Save","Cancel",new{@class="SPSave"})
               }                        
           </text>
          ))
      .Events(events => events
          .DataBinding("onGridDataBinding")
          .Change("onGridSelectionChanged")
          .DataBound("onGridDataBound") 
      )
    )

}

提前, 弗兰克

1 个答案:

答案 0 :(得分:0)

类似的东西:

       .ToolBar(b => b.Template(@"<div class='grid-column-right'> 
                <a class='k-button k-button-icontext k-grid-add' style='margin-right:40px; ' href='javascript: add(0)'>+ Add</a> 
                <a class='k-button k-button-icontext k-grid-refresh' href='javascript: refreshGridByName(""FilePattern#=uid#"")'>Refresh</a>
                </div>"))