Hello.
When some error occures on server-side during Scheduler request, this error is transferred to client as 400 Bad request with some description. Then in dataSource error handler function I show modal window with error description:
JS:
01.
self.dataSourceError =
function
(xhr, error) {
02.
if
(xhr.xhr.responseJSON && xhr.xhr.responseJSON.ErrorDescription) {
03.
self.showError(xhr.xhr.responseJSON.ErrorDescription);
04.
}
else
{
05.
self.showError(xhr.xhr.responseText);
06.
}
07.
};
08.
09.
self.showError =
function
(text) {
10.
var
errorWindow = self.getErrorWindow();
11.
12.
self.errorMessage = text;
13.
$scope.$apply();
14.
errorWindow.center();
15.
errorWindow.open();
16.
};
17.
18.
self.getErrorWindow =
function
() {
19.
if
(angular.isUndefined(self.errorWindow)) {
20.
return
$(
"#errorModal"
).data(
"kendoWindow"
);
21.
}
22.
return
self.errorWindow;
23.
};
Error window HTML:
01.
<
div
kendo-window
=
"main.errorWindow"
k-title
=
"'Ошибка'"
id
=
"errorModal"
02.
k-width
=
"450"
k-height
=
"130"
k-visible
=
"false"
k-modal
=
"true"
03.
k-resizable
=
"false"
k-pinned
=
"true"
k-draggable
=
"false"
>
04.
<
div
class
=
"error-message"
>
05.
{{main.errorMessage}}
06.
</
div
>
07.
<
div
class
=
"error-ok-button"
>
08.
<
button
class
=
"k-button k-primary"
ng-click
=
"main.errorWindow.close()"
>OK</
button
>
09.
</
div
>
10.
</
div
>
Now, while error window is shown, the editor form is automatically closed in background.
But I need Editor window to stay opened while user do not press cancel button or while save operation on server does not succeed.
How I can acomplish this?
I already tried such code from this forum: (this post)
1.
var
scheduler = $(
"#scheduler"
).data(
"kendoScheduler"
);
2.
3.
scheduler.one(
"dataBinding"
,
function
(e) {
4.
e.preventDefault();
// cancel grid rebind if error occurs - this prevents window to closing
5.
6.
/* some error handling */
7.
});
But this code (while doing what I need to do at the first look) breaks widget - if user will press OK button for second time there will be an error in console something about "Cannot read property *** of undefined" - I dont remember property name. This error fires from somewhere in kendo source code.