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

Is there a way to retrieve the Identity value after Create operation?

1 Answer 46 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Wayne
Top achievements
Rank 1
Wayne asked on 23 Aug 2012, 04:27 AM
I need to get the row identity value of the newly created record so that I can tie it to other data. How can I extract the results in the change event?

For example...

var dsEmployee = new kendo.data.DataSource({
 type: "odata",
 transport: {
  read: {
   url: baseUrl + "/DataService.svc/Employees",
   dataType: "json"
  },
  create: {
   url: baseUrl + "/DataService.svc/Employees",
   type: "POST",
   dataType: "json"
  },
  update: {
   url:  function (o) {
    return baseUrl + "/DataService.svc/Employees(" + o.EmployeeId + ")"
   },type: "PUT",
   dataType: "json"
  }
 },
 schema: {
  model: Employee
 },change: function (e) {
  ...
 
 }
}

1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 27 Aug 2012, 02:11 PM
Hi Wayne,

In order to get the id of the newly inserted record after sync operation, you should re-retrieve the model instance by its uid. Here you can find a basic sample which demonstrates this approach. 

All the best,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Wayne
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or