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

ID of new item in Kendo UI data source

3 Answers 369 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
João
Top achievements
Rank 1
João asked on 21 Aug 2012, 02:10 PM
When I create a new item in the server-side using a Kendo UI data sourcehow do I update the ID of the client-side data item with the ID of the new record inserted in the database in the server-side?

3 Answers, 1 is accepted

Sort by
0
João
Top achievements
Rank 1
answered on 21 Aug 2012, 02:28 PM
Doing more research I have found this extremely useful information which, indeed, should be in the docs, but it is "hidden" in a not-so-easy-to-find forum search message:

http://www.kendoui.com/forums/ui/grid/refresh-grid-after-datasource-sync.aspx#2124402

This solution simply uses the data source read method to update the model instances with data from server.

The precious info is where it is done: in the "complete" event of the transport.create object!
0
erwin
Top achievements
Rank 1
Veteran
answered on 13 Nov 2012, 01:39 PM
João,

just see my latest post in the thread that you linked.
If your create method returns the data according to the model including the modified fields such as "id", the datasource and the grid update themselves without an additional roundtrip.

Regards
Erwin
0
Jeroen
Top achievements
Rank 1
answered on 13 Nov 2012, 10:29 PM
Hi João,

If you want to avoid coupling the DOM to your datasource (which isn't that smart if you ask me), maybe this will be helpful:

http://www.kendoui.com/forums/framework/data-source/data-source-add-sync-promises.aspx#2372918

Kind regards,


Jeroen
Tags
Data Source
Asked by
João
Top achievements
Rank 1
Answers by
João
Top achievements
Rank 1
erwin
Top achievements
Rank 1
Veteran
Jeroen
Top achievements
Rank 1
Share this question
or