0

I have kendo-ui grid, with some fields. I need one of the fields to be editable on add new row, and not editable on update row.

I try to change data-source definitions before add row, and change it back before update.

But the changing doesn't help.

Is there any way to do it?

Here is what I tried to do:

 var schema = {
                data: 'results',
                model: {
                    id: 'GroupCode',
                    fields: {
                        GCode: { editable: false },
                        GroupPrincipalId: { editable: false },
                        GroupPrincipalName: { editable: false },
                        ChildCount: { editable: true },                          
                    }
                }
            };

onAddClick: function(){
  var gridElement = ('#myGrid').data('kendoGrid');
      gridElement.dataSource.options.schema.model.fields.GroupPrincipalId.editable = true;
      gridElement.dataSource.options.schema.model.fields.GroupPrincipalName.editable = true;

      gridElement.addRow();
}

(onAddClick is called by my custom adding-button, not related to kendo-adding-logic);

user5260143
  • 1,048
  • 2
  • 12
  • 36

1 Answers1

0

You can use the approach described here:

http://www.telerik.com/forums/making-column-as-readonly-on-update-and-editable-on-insert-in-grid

When create button is pressed you mark a variable as isCreating and in the edit section you check it and if is false you disable the requiered field/fields.

calinaadi
  • 1,466
  • 1
  • 13
  • 22