Domanda

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?

È stato utile?

Soluzione

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);
});

Altri suggerimenti

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);

   }
}
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top