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

2 posts, 0 answers
  1. Wayne
    Wayne avatar
    1 posts
    Member since:
    Jul 2012

    Posted 22 Aug 2012 Link to this post

    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) {
      ...
     
     }
    }
  2. Rosen
    Admin
    Rosen avatar
    3253 posts

    Posted 27 Aug 2012 Link to this post

    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!
Back to Top