This is a migrated thread and some comments may be shown as answers.

How to show error from JSON ?

2 Answers 309 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Gert
Top achievements
Rank 1
Gert asked on 07 Feb 2015, 07:24 AM
Hello,

Wenn someone adds or modifies a task, the server checks if this is possible or not.
​At certain dates or times a task cannot created (holidays, already another task,....).
​The server/database  checks if this is possbile or not. if not I return a errormessage within a JSON.
​How do I show this errormessage to the user in de scheduler-popup window ?
 

2 Answers, 1 is accepted

Sort by
0
Gert
Top achievements
Rank 1
answered on 10 Feb 2015, 11:24 AM
Solved, Please remove this topic.
0
Vladimir Iliev
Telerik team
answered on 10 Feb 2015, 01:02 PM
Hello Gert,

You can subscribe to the "error" event of the dataSource which is triggered either by HTTP error or if the response from the server contains field, described in the "dataSource.schema.errors" option. Then inside the "error" event handler you can notify the user for the server error and prevent the next "dataBinding" event of the scheduler - this way the edit window will remain open.

e.g.:
function error_handler(e) {
    if (e.errors) {
        var message = "Errors:\n";
        $.each(e.errors, function (key, value) {
            if ('errors' in value) {
                $.each(value.errors, function () {
                    message += this + "\n";
                });
            }
        });
        alert(message);
 
        var scheduler = $("#scheduler").data("kendoScheduler");
        scheduler.one("dataBinding", function (e) {
            //prevent saving if server error is thrown
            e.preventDefault();
        })
    }
}



Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Scheduler
Asked by
Gert
Top achievements
Rank 1
Answers by
Gert
Top achievements
Rank 1
Vladimir Iliev
Telerik team
Share this question
or