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

Prevent Editor window from closing on dataSource error

3 Answers 125 Views
Scheduler
This is a migrated thread and some comments may be shown as answers.
Loeschke
Top achievements
Rank 1
Loeschke asked on 21 Sep 2015, 07:41 PM

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.

 

3 Answers, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 23 Sep 2015, 09:26 AM
Hello,

I tried to reproduce the problem locally but to no avail – everything is working as expected on our side. Could you please provide runable project where the issue is reproduced? This would help us pinpoint the exact reason for this behavior.

Regards,
Vladimir Iliev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Loeschke
Top achievements
Rank 1
answered on 24 Sep 2015, 07:18 AM

Hello, Vladimir.

It will be difficult for me to create a runnable example, because there is many lines of specific code, and simply copy-paste to Dojo is not working. But can you provide an example - what is the right way of implementing this behaviour? For reminder: I want Editor window to stay opened while user do not press cancel button or while save operation on server does not succeed. Maybe I'll look at it and find, what I'm doing wrong.

Thanks.

0
Vladimir Iliev
Telerik team
answered on 24 Sep 2015, 09:32 AM
Hello,

For your convenience I created small example which you can use as baseline to reproduce the issue and send it back to us. The example is attached to the current thread.

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
Loeschke
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Loeschke
Top achievements
Rank 1
Share this question
or