ID of new item in Kendo UI data source

4 posts, 0 answers
  1. João
    João avatar
    8 posts
    Member since:
    Jan 2012

    Posted 21 Aug 2012 Link to this post

    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?
  2. João
    João avatar
    8 posts
    Member since:
    Jan 2012

    Posted 21 Aug 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. erwin
    erwin avatar
    358 posts
    Member since:
    Dec 2006

    Posted 13 Nov 2012 Link to this post

    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
  5. Jeroen
    Jeroen avatar
    4 posts
    Member since:
    Jun 2012

    Posted 13 Nov 2012 Link to this post

    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
Back to Top
Kendo UI is VS 2017 Ready