Pending Review
Last Updated: 20 Dec 2019 09:33 by Daniel Blendea
Andy
Created on: 18 May 2015 20:24
Category: Data Source
Type: Feature Request
5
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.  http://www.telerik.com/forums/if-id-is-provided-in-add()-sync-does-not-update-_pristinedata-and-create-update-are-not-invoked

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. 
4 comments
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! 
Fan
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.