Our pure JavaScript Scheduler component


Post by Edouard »

Hello,

I try to handle server error response after an event delete. My goal is to display a Toast with the returned error message.

My eventSore :

const eventStore = new bryntum.scheduler.EventStore({
  modelClass : kaplanAssignment,
  createUrl : 'path/to/my/dotnet/controller/Create/',
  readUrl : 'path/to/my/dotnet/controller/Load/',
  updateUrl : 'path/to/my/dotnet/controller/Update',
  deleteUrl : 'path/to/my/dotnet/controller/Delete',
  autoLoad : true,
  autoCommit : true,
});

My understanding of the https://www.bryntum.com/docs/scheduler/#Core/data/AjaxStore#event-exception is that the Exception event should fire when the server response (of the Delete auto-commit) is a 400 http code.

So I set my listeners like this :

listeners : {
    exception({action, exceptionType, response}) {
        bryntum.scheduler.Toast.show({
            color: 'b-red',
            html: response.parsedJson.message,
            showProgress: false
        });
    }
}

And for testing purpose I set my dotnet controller to return a json response like this :

{"message":"unexpected error","success":false}

using the following c# code:

// send a response with 400 statusCode
return BadRequest(new SchedulerErrorResponse {
    success = false,
    message = "unexpected error"
});

Here is the result :

  • the Exception event never fires when I click the Delete button of the eventEditor
  • I have an uncaught exception in dev tools :
    Screenshot_1.png
    Screenshot_1.png (26.09 KiB) Viewed 409 times
    Note that the Uncaught error contains an object that complies with the documentation.

I tried to set the server response with a 200 statusCode, thinking that the success property of the response body would suffice to fire the event but it doesn't work either. But in this case I no longer have an uncaught error in dev tools.

What am I missing out? What are the expected situations where the Exception event is supposed to fire?

Thx,
Edouard


Post by Edouard »

Ok, I figured out that I was defining the Exception event at Scheduler level, not at Store Level. Moreover the use of the store#afterRequest event is more appropriate because I can show a Toast for every situation (success or error).

With the good event in the good listeners object everything works fine :)


Post by pmiklashevich »

You can check out our PHP demo: scheduler/examples/php/

Add "/%" to the end of the read URL for event store.

    eventStore : {
        ....
        readUrl        : 'php/event/read.php/%',
        ....

Then go to the browser and reload the page. See the Toast is shown

Снимок экрана 2021-05-06 в 16.16.16.png
Снимок экрана 2021-05-06 в 16.16.16.png (521.39 KiB) Viewed 396 times

Pavlo Miklashevych
Sr. Frontend Developer


Post by pmiklashevich »

Ok, I figured out that I was defining the Exception event at Scheduler level, not at Store Level. Moreover the use of the store#afterRequest event is more appropriate because I can show a Toast for every situation (success or error).

With the good event in the good listeners object everything works fine :)

Glad to hear it works for you!

Pavlo Miklashevych
Sr. Frontend Developer


Post Reply