Oniel Telies
Oniel Telies

Reputation: 155

Keep kendo grid non-editable but still add rows

Here I want the Grid to work in such way that,I can't edit the value of Student's ID but while Adding ID has to be editable. I can use model.Field(p => p.ID).Editable(false) but it will wont let me edit while adding

@(Html.Kendo().Grid(Model).Name("StudentModel")
        .Columns(column =>
        {
          column.Bound(p => p.ID).Width(30).EditorTemplateName("#=GetID(this)#");
          column.Bound(p => p.First_Name).Width(100);
          column.Bound(p => p.Last_Name).Width(100);
          column.Bound(p => p.Division).Width(30);
          column.Bound(p => p.Standard).Width(30);
          column.Bound(p => p.Percentage).Width(50);
        })
        .Selectable()
        .Sortable()
      .Editable(editable => editable.Mode(GridEditMode.InCell).DisplayDeleteConfirmation(false)).Navigatable()
        .Filterable()
        .DataSource(datasource=>datasource
        .Ajax()
        .ServerOperation(false)
            .Model(model =>
            {
              model.Id(p => p.ID);
            }))
    )

Upvotes: 1

Views: 285

Answers (1)

GeorgeB
GeorgeB

Reputation: 848

How are you adding rows? I assume with a button outside of the grid?

If so, you could get the click event of that button, loop through the grid and set editable where student id == null, you could also run this on the event when the kendo grid gets loaded.

Upvotes: 1

Related Questions