Kendo UI for MVC Grid How to hide an identifier column

I would like to hide the Kendo grid id column, but still can reference it for other actions. I tried to make Width = 0, but that only makes it very wide.

@(Html.Kendo().Grid(Model)
        .Name("LineItems")
        .Columns(columns =>
            {
                columns.Bound(o => o.ID).Width(1);
                columns.Bound(o => o.Ui).Width(20);
                columns.Bound(o => o.QtyOrdered).Width(20);
                columns.Bound(o => o.Nomenclature).Width(200);
                columns.Bound(o => o.QtyShipped).Width(140);
                columns.Bound(o => o.QtyReceived).Width(200);
                columns.Bound(o => o.Hazmat).Width(50);

            })

Edit June 26

OK I was able to get a reasonable solution based on a message from the Kendo forum. As long as the identifier is defined in the data source, the column should not be defined in the grid. You still have access to the id value. I wrote a quick snippet to prove this, and it returns an identifier without an ID column in the grid.

<script>
  $(document).ready(function () {
      $("#btn").on("click", function () {

          var grid = $("#LineItems").data("kendoGrid");
          var data = grid.dataSource.data();
          $.each(data, function (i, item) {
              alert(item.ID);
           });
      });
  });
</script>
+4
source share

All Articles