Last Updated: 23 Jun 2021 08:13 by ADMIN
Created on: 18 May 2015 20:24
Category: Data Source
Type: Feature Request
On DataSource, If ID is provided in add(), sync does not update _pristineData and Create/Update are not invoked.
Currently when the add() method is called on a DataSource, if the id, as defined in the Model, is included, then the sync method is called, the data is not persisted to the _pristineData object, and neither the Create nor Update transports are called.  This has the effect of not persisting the data and so if the cancel button is pushed on an edit screen, the added object is mysteriously dropped.  

Please see my post on the kendo forums for a more detailed explanation including demos of the issue.

I would suggest that anytime the add() method is used, it should be considered a 'new' record, or at least when the id provided does not match with any other id currently in the data array. If it matches a record in the data array, run the Update transport, otherwise, run the Create transport.  Simply including a value for the id should not remove the record from ever being persisted. 
Angel Petrov
Posted on: 23 Jun 2021 08:13


We do check for internal IDs properties values, the default case if the value is null we consider the item as new. This is a design decision and altering the logic will lead to non-desirable effects.

A solution would be to define a default id value but since in the current example it has a specific value and I suggest others will have too it is not suitable. With the local array of data the correct approach would be to add the id value in the create transport method as shown here(have in mind that the ids should be unique). As for the case with remote operations generally databases have their ID fields autotically generated and that is why providing values for these is not needed thus the approach we have choosen works out of the box.

Angel Petrov
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Daniel Blendea
Posted on: 20 Dec 2019 09:33

In EF/EF Core, an object whose "Id" property is equal to 0 is considered New, so the framework will try to insert it.

I'm pretty sure this is a very common convention.

Imported User
Posted on: 09 Nov 2016 09:47
+++ it confused me too! 
Posted on: 09 Apr 2016 10:09
this is also confusing me.
Imported User
Posted on: 17 Jun 2015 07:52
I suggest this should be handled. At times we need to fill the data to grid only at UI and when page is saved completely we pass all the records and save to DB.
With this approach I have to now somehow have either a temporary id or save records to temp table, which does not help.