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

Multiple syncs with one success action?

3 Answers 70 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Brett
Top achievements
Rank 2
Brett asked on 25 Jan 2013, 06:15 PM
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.

3 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 29 Jan 2013, 09:09 AM
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!
0
Brett
Top achievements
Rank 2
answered on 29 Jan 2013, 02:27 PM
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!');
});
0
Petur Subev
Telerik team
answered on 31 Jan 2013, 12:12 PM
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!
Tags
Data Source
Asked by
Brett
Top achievements
Rank 2
Answers by
Petur Subev
Telerik team
Brett
Top achievements
Rank 2
Share this question
or