Dhtmlx scheduler .net core

Refresh data after add event in database, but in dhtmlx scheduler data are visible before event added in database.

Hi!

scheduler will add the event on the client and will only wait for a confirmation from the server to get a permanent event id.
If you want to refresh the data on the client in order to ensure it’s in sync with the server, then cleaning and reloading the calendar using scheduler.clearAll(); and scheduler.load(url) is a way to go:

scheduler.clearAll();
scheduler.load(url);

https://docs.dhtmlx.com/scheduler/api__scheduler_load.html
https://docs.dhtmlx.com/scheduler/api__scheduler_clearall.html

In order to trigger the refresh after adding a new event, or any other action that require a confirmation from the server, you can use the API of the dataProcessor:

var dp = new dataProcessor("/api/events");
dp.init(scheduler);
...
dp.setTransactionMode("REST");

dp.attachEvent("onAfterUpdate", function(id, action, tid, response){
    scheduler.clearAll();
    scheduler.load(url);
});

https://docs.dhtmlx.com/scheduler/server_integration.html#errorhandling

If you want to refresh only after specific actions (e.g. after new event was created but not after it was updated), then you’ll need to inspect the action argument of “onAfterUpdate” event:

dp.attachEvent("onAfterUpdate", function(id, action, tid, response){
    if (action == "inserted") {
        scheduler.clearAll();
        scheduler.load(url);
    }
});

The values of the action argument are defined in the controller:
https://docs.dhtmlx.com/scheduler/howtostart_dotnet_core.html#step4implementingwebapi
“inserted”, “updated”, and “deleted” are fixed names that are needed for the dataprocessor to handle the server response correctly.

You may want to ensure the dynamic loading is enabled https://docs.dhtmlx.com/scheduler/howtostart_dotnet_core.html#dynamicloading in order to minimize the loading delays.

You can also display ajax spinner when the loading is in progress: https://docs.dhtmlx.com/scheduler/api__scheduler_show_loading_config.html it’s possible to override the looks of ajax icon with css:

.dhx_loading{
   background-image: url(....);
   width: 100px;
   height: 100px;
}

And finally, if loading takes a noticeable amount of time and you want to ensure the scheduler stays read-only while reloading is in progress, you’ll need to set readonly flag manually:

scheduler.attachEvent("onLoadStart", function(){
    scheduler.config.readonly = true;
});
 
scheduler.attachEvent("onLoadEnd", function(){
    scheduler.config.readonly = false;
});

https://docs.dhtmlx.com/scheduler/api__scheduler_onloadstart_event.html