My grid is showing the ID in a column. The ID however is coming from the database and can't be changed. Also, the database creates it when adding a new item.
In other words: editing the ID when adding or editing a new item makes no sense.
How can I achieve this?
Here is what I tried:
@(Html.Kendo().Grid<DepartmentModel>()
.Name("departmentsGrid")
.HtmlAttributes(new { @class = "controls-default" })
.Columns(c =>
{
c.Bound(x => x.Id);
c.Bound(x => x.Name);
c.Bound(x => x.Description);
c.Command(b =>
{
b.Edit();
b.Destroy();
});
})
.ToolBar(b => b.Create())
.Editable(b => b.Mode(GridEditMode.PopUp))
.Sortable()
.Scrollable()
.Pageable(x => x.Refresh(true).PageSizes(true).ButtonCount(5))
.DataSource(b => b.Ajax()
.Model(model =>
{
model.Id(x => x.Id);
model.Field(x => x.Id).Editable(false);
})
.Read(x => x.Action("ReadDepartments", "Departments").Data("getReadDepartmentsParameters"))
.Create(x => x.Action("CreateDepartment", "Departments"))
.Update(x => x.Action("UpdateDepartment", "Departments"))
.Destroy(x => x.Action("DeleteDepartment", "Departments"))))