Show Animation for long running tasks

We're using the Schedule control and binding to a web service (DataManager with WebMethodAdaptor).

When actionBegin event fires for event create/change/remove, we call a web service and the processing can take as much as 10 seconds. We'd like to show a "Processing..." animation.

We tried showing our HTML/Image animation, but the AJAX call is started so quickly that the animation doesn't display (race condition). We tried using a setTimeout, but that tells actionBegin that the event is done (since the processing is pushed to a new thread) and .

Any suggestions?


4 Replies

BP Brian Pautsch July 7, 2023 05:34 PM UTC

This works, but feels hacky. Are there better options?

actionBegin: function (args) {

    if (args.requestType === 'eventCreate' || args.requestType === 'eventChange' || args.requestType === 'eventRemove') {

        ShowAnimation();

        setTimeout(function () {

            UpdateScheduleTask(args);

            HideAnimation();

        }, 50);

    }

},




VS Venkateshwaran Saravanakumar Syncfusion Team July 10, 2023 11:43 AM UTC

Hi Brian,     

We suggest you to use the "actionComplete" event of the Scheduler as a replacement for the setTimeout function, as shown in the highlighted code snippet below.

[index.js]

var data = new ej.base.extend([], window.scheduleDatanulltrue);

var scheduleObj = new ej.schedule.Schedule({

    width: '100%',

    height: '650px',

    selectedDate: new Date(2021010),

    eventSettings: { dataSource: data },

    actionBegin: OnActionBegin,

    actionComplete: OnActionComplete

 

});

scheduleObj.appendTo('#Schedule');


function
 OnActionBegin(args) {

    if (args.requestType === 'eventCreate' || args.requestType === 'eventChange' || args.requestType === 'eventRemove') {

        //Your customized show animation codes can be given here

        ShowAnimation();

    }

}

function OnActionComplete(args) {

    if (args.requestType === 'eventCreated' || args.requestType === 'eventChanged' || args.requestType === 'eventRemoved') {

        //Your customized Hide animation codes can be given here  

        UpdateScheduleTask(args);

        HideAnimation();

    }

}

 



Regards,
Venkatesh



BP Brian Pautsch replied to Venkateshwaran Saravanakumar July 10, 2023 03:13 PM UTC

That worked perfectly. Thank you. Your forum support is excellent!



RV Ravikumar Venkatesan Syncfusion Team July 12, 2023 07:13 AM UTC

Brian,


You're welcome! Thanks for your feedback.


Loader.
Up arrow icon