This is a migrated thread and some comments may be shown as answers.

Trying to understand Grid Editing

1 Answer 8 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 12 Oct 2015, 05:34 PM

 I've setup a grid with inline editing, and have the following for transport code.  (Using local data).  Why would the create event fire when I click the update button instead of the update event?

It may also help me if someone could explain what happens when the edit button is clicked in regards to what events are fired, etc.

 

"columnData" is a local dataset, and in reality I don't think I need the create as I don't have any functionality to add rows.  This is just a simple editable grid where a user is allowed to edit 3 out of 4 columns with the first column being read only.

 

transport: {
     read: function(e) {                              
        e.success(columnData);
     },
     update: function(e) {
        e.success();
     },
     create: function(e) {
        var item = e.columnData;
        item.Id = columnData.length + 1;
        e.success(item);
     }

1 Answer, 1 is accepted

Sort by
0
Boyan Dimitrov
Telerik team
answered on 14 Oct 2015, 07:51 AM

Hello Matt,

 

The Kendo UI DataSource differentiate creating a new item and updating an existing item based on the model id value of the data item. If the model id is integer type the default value is "0". When an new item is created the model id value is set to "0" and the Kendo UI DataSource will use the create operation.

 

Please refer to the Complete example: Local CRUD Operations with the Kendo UI Grid example. 

 

I modified the http://dojo.telerik.com/afiDE example in order to demonstrate the described behavior. The "Apple iPhone 5s" product has a ProductID set to "null" (the nullable property for  ProductID model field is enabled) . If you try to update this item the create operation will be fired. 

 

Regards,
Boyan Dimitrov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Grid
Asked by
Matt
Top achievements
Rank 1
Answers by
Boyan Dimitrov
Telerik team
Share this question
or