how to get selected row value in the KendoUI

前端 未结 4 1399
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-22 23:41

I have a kendoUI grid.

                @(Html.Kendo().Grid()
                    .Name(\"EntitesGrid\")
                                .Html         


        
4条回答
  •  天命终不由人
    2020-12-23 00:23

    One way is to use the Grid's select() and dataItem() methods.

    In single selection case, select() will return a single row which can be passed to dataItem()

    var entityGrid = $("#EntitesGrid").data("kendoGrid");
    var selectedItem = entityGrid.dataItem(entityGrid.select());
    // selectedItem has EntityVersionId and the rest of your model
    

    For multiple row selection select() will return an array of rows. You can then iterate through the array and the individual rows can be passed into the grid's dataItem().

    var entityGrid = $("#EntitesGrid").data("kendoGrid");
    var rows = entityGrid.select();
    rows.each(function(index, row) {
      var selectedItem = entityGrid.dataItem(row);
      // selectedItem has EntityVersionId and the rest of your model
    });
    

提交回复
热议问题