Hi,
I have put in a general error handling to handle exceptions and authorisation errors for all Ajax calls, both Kendo and my api. I send back status 500 of exception and 401, Forbidden, or 403, Unauthorized, for authorisation errors.
The problem is I do not seem to be able to prevent the dataSource from updating the display if I get a non-200, OK, response. Looking at the code in Chrome it does not call the function associated with 'databinding' on line 13 of the code below.
Can you suggest what I have done wrong?
Thanks in advance.
I have put in a general error handling to handle exceptions and authorisation errors for all Ajax calls, both Kendo and my api. I send back status 500 of exception and 401, Forbidden, or 403, Unauthorized, for authorisation errors.
The problem is I do not seem to be able to prevent the dataSource from updating the display if I get a non-200, OK, response. Looking at the code in Chrome it does not call the function associated with 'databinding' on line 13 of the code below.
01.
function
kendoGridErrorHandler(args) {
02.
if
(args.errors == undefined) {
03.
if
(args.xhr.status == 403) {
04.
updatePrimaryMessage(
"You are not authorised to carry out that operation."
,
true
);
05.
}
else
if
(args.xhr.status == 401) {
06.
updatePrimaryMessage(
"You need to be logged in to carry out that operation."
,
true
);
07.
}
else
if
(args.xhr.status == 500) {
08.
updatePrimaryMessage(
"The operation did not complete because of an error."
,
true
);
09.
}
else
{
10.
updatePrimaryMessage(
"There was problem. Please refresh the screen."
,
true
);
11.
}
12.
$(
'#PrimaryKGrid'
).data().kendoGrid.one(
'dataBinding'
,
function
(e) {
13.
e.preventDefault();
14.
});
15.
}
else
{
16.
//error means Ajax error response. customerror means Kendo error response
17.
var
grid = $(
'#PrimaryKGrid'
).data(
"kendoGrid"
);
18.
grid.one(
"dataBinding"
,
function
(e) {
19.
e.preventDefault();
// cancel grid rebind if error occurs
20.
//We have formatted errors to display
21.
for
(
var
error
in
args.errors) {
22.
showMessage(grid.editable.element, error, args.errors[error].errors);
23.
}
24.
});
25.
}
26.
}
Thanks in advance.