Kendo网格行不存在data-id属性

时间:2014-03-04 22:56:54

标签: jquery html razor kendo-ui kendo-grid

我有一个Kendo网格,设置如下所示,字段ASPNetUserName指定为模型ID。我期望生成的行包含“data-id”属性,这将允许我选择所需的行。不幸的是,为每个网格行生成的唯一html是“<tr class="k-alt">”,因此我无法选择所需的行。

我希望网格中每行的输出都像<tr data-id="joeUser">data here</tr>

@(Html.Kendo().Grid<Analytics.Web.Models.UserModel>() 
      .Name("InternalUserGrid")
      .DataSource(ds => 
          ds.Server()
          .Model(m => m.Id(i => i.UserName))
          .Destroy(d => d.Action("Delete", "InternalUser"))
          .Update(u => u.Action("Edit", "InternalUser"))
          .Create(c => c.Action("Create", "InternalUser"))
          )
      .ToolBar(toolbar => toolbar.Create().HtmlAttributes(new {id = "createButton"}))   
      .BindTo(Model)
      .Columns(columns =>
          {
              columns.Bound(u => u.UserName).Width(250);
              columns.Command(c => { c.Destroy();c.Edit();} );
          })
      .Editable(e => e.Mode(GridEditMode.PopUp))
      .Resizable(r=> r.Columns(true))
      .Selectable()
      .Scrollable())

1 个答案:

答案 0 :(得分:0)

尝试像这样设置网格选择

.Selectable(s => s.Mode(GridSelectionMode.Single).Type(GridSelectionType.Row))

然后

 $('#Grid').click(function () {
    var gview = $(this).data("kendoGrid");
    var selectedItem = gview.dataItem(gview.select());
    var Guid = selectedItem.UserName;
 }