dataSource.sync() callback

5 posts, 0 answers
  1. DJo
    DJo avatar
    23 posts
    Member since:
    Nov 2012

    Posted 19 Apr 2013 Link to this post

    Can I add a callback function to the dataSource sync() method? I want code to wait until after the sync() is finished before proceeding because subsequent code is querying the data that is updated by the sync().

    I don't want to use the dataSource's change event because I need to stay in scope where I manually call the sync() method.
  2. DJo
    DJo avatar
    23 posts
    Member since:
    Nov 2012

    Posted 19 Apr 2013 Link to this post

    Solved it myself. I did use the sync event, which turned out to have some advantages.
  3. Kendo UI is VS 2017 Ready
  4. DJo
    DJo avatar
    23 posts
    Member since:
    Nov 2012

    Posted 30 Jul 2013 Link to this post

    Change my mind. This would be really useful and in keeping with jQuery norms.

    Is there a way to add a callback function to the dataSource.sync() method? I want to sometimes execute a function after sync but not always.
  5. Rosen
    Admin
    Rosen avatar
    3234 posts

    Posted 01 Aug 2013 Link to this post

    Hello DJo,

    I'm afraid that such callback is not available. As you have already noted the sync event should be used instead. You may know it is possible to use the one method to attach a event handler only once when it is required.
    Other useful events in this case are change event (which in this case will have e.action argument set to sync), as well as requestEnd event which is raised before data is processed, providing access to the raw response.

    Regards,
    Rosen
    Telerik
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  6. Anthony
    Anthony avatar
    2 posts
    Member since:
    Jun 2016

    Posted 18 Nov Link to this post

    Hello, I just wanted to update this post since the sync function now returns a promise.  So, you can do something like this:

    myGrid.dataSource.sync().then(function() {

        //callback logic in here

    });

Back to Top
Kendo UI is VS 2017 Ready