Multiple syncs with one success action?

4 posts, 0 answers
  1. Brett
    Brett avatar
    25 posts
    Member since:
    Sep 2012

    Posted 25 Jan 2013 Link to this post

    I have a unique situation where I have three DataSources that are sync'd at the same time when a user clicks the save button. I have the Kendo UI Progress control displayed when user clicks the button, but I only want it to hide when the longest of the three ajax calls completes. I am familiar with jQuery's $.ajaxCompelete() function, but it runs for every ajax call. How can I determine which call is the last? Do take note that not all three DataSource syncs occur, because if there are no changes in it, then it's ajax call is not initiated.
  2. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 29 Jan 2013 Link to this post

    Hello Brett,

    You can combine the usage of the requestStart event and requestEnd events of the dataSource with a simple counter. 
    Each time the requestStart is triggered show the animation and increase the counter. Each time the requestEnd event is triggered decrease the counter and if it is equal to 0 then hide the loading animation.

    Regards,
    Petur Subev
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Brett
    Brett avatar
    25 posts
    Member since:
    Sep 2012

    Posted 29 Jan 2013 Link to this post

    That might work for me, but, might I suggest that the dataSource.sync() method or some other property returns a promise to the transport ajax call, then you could use them like this:
    $.when(dataSource1.sync, dataSource2.sync, dataSource3.sync).done(function() {
      alert('All data source syncs have completed!');
    });
  4. Petur Subev
    Admin
    Petur Subev avatar
    1882 posts

    Posted 31 Jan 2013 Link to this post

    Hello again Brett,

    I would suggest you to forward your idea to our User Voice Page where people can vote for it. More votes mean higher chances to consider adding it.

    Thank you for the understanding.

    Kind Regards,
    Petur Subev
    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