3

Trying to add spinner (kendo.ui.progress) to show crud operations in process, for create start spinner in save event and end in databound but for delete(destroy) start in remove event, but there is no way to tell when destroy is completed. There is event requestEnd but it never gets called -- probably it is not supported in older version of kendo ui.

There is one more way which is define ajax function inside destroy operation like destroy:function(options){$.ajax...} and in success or failure callbacks of ajax stop spinner but I do not want to do this.

Is there a way I can know when the destroy operation completed other than the above two mentioned solutions?

peak
  • 105,803
  • 17
  • 152
  • 177
user2539301
  • 33
  • 1
  • 4

2 Answers2

2

Using requestStart, sync, requestEnd to show and hide a spinner is not wise. This way you have to write code for showing and hiding spinner in every datasource. what happens if the code of showing/hiding changed?

Better idea is defining a global handler to show spinner after first request and hide spinner after last response. Global Ajax Event Handlers is best in this scenarios.

.ajaxStart():Register a handler to be called when the first Ajax request begins.

.ajaxStop():Register a handler to be called when all Ajax requests have completed.


example:

$( document ).ajaxStart(function() {
    kendo.ui.progress($("#app"), true);
});
//----------------------------------------------
$( document ).ajaxStop(function() {
    kendo.ui.progress($("#app"), false);
});
Iman Mahmoudinasab
  • 6,861
  • 4
  • 44
  • 68
  • WOW!, best solution and it worked, thank you so much for answering clearly that too with example. – user2539301 May 12 '14 at 03:08
  • @user2539301: you're welcome and I'm happy solved your problem. One advice to you is changing your question title and make it more specific. And if you want to know why `requestEnd` never gets called open another new question. – Iman Mahmoudinasab May 12 '14 at 05:41
0

You can use the sync event. It is fired after the data source saves data item changes. http://docs.telerik.com/kendo-ui/api/framework/datasource#events-sync

dataSource    : {
   transport   : {
     read: {
         url:...
     }
   },

   sync: function () {
      kendo.ui.progress($("#loading"), false);

   }
}
Rick S
  • 6,476
  • 5
  • 29
  • 43