DisplayName
DisplayName

Reputation: 195

Is there a way to enable row editing on only new added rows within a Kendo grid?

So I have a standard Kendo grid in MVC with 2 non-editable columns. What I would like to achieve is to enable editing of all columns only within the newly added rows.

Example: There's 4 rows already in the grid, first 2 columns non-editable. User clicks "Add new", a new record appears in the grid with everything editable.

Upvotes: 1

Views: 1280

Answers (1)

Joe Glover
Joe Glover

Reputation: 1026

Try adding an editable function handler to your column definition, something like this:

{
  field: "salary",
    editable: function (dataItem) {
      return dataItem.isNew();
    }
}

Please note: you will need to have specified an id column in your model definition for this to work, for details see isNew documentation:

Checks if the Model is new or not. The id field is used to determine if a model instance is new or existing one. If the value of the field specified is equal to the default value (specified through the fields configuration) the model is considered as new.

Upvotes: 1

Related Questions