We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Angular : prevent Closing the Edit Window issue

Thread ID:

Created:

Updated:

Platform:

Replies:

144175 Apr 23,2019 02:15 PM UTC Jan 23,2020 07:40 AM UTC Angular - EJ 2 7
loading
Tags: Schedule
JMEL Becha
Asked On April 23, 2019 02:15 PM UTC

Hi every one,
I'm tring to cancel the colsing of the Edit Window but having some trouble.

here is my code :
HTML File
<ejs-schedule #scheduleObj
(actionBegin)="onActionBegin($event)"
(dataBound)="onDataBound()"></ejs-schedule>

TS File
cancel : boolean = false;
@ViewChild("scheduleObj")
scheduleObj: ScheduleComponent;
onActionBegin(args: ActionEventArgs): void {
var data = (args.requestType === 'eventCreate') ? args.data[0] : (args.data);
if(data && (data.StartTime>data.EndTime))
{
args.cancel = true;
this.cancel = true;
}
}

onDataBound() {
this.scheduleObj.eventWindow.dialogObject.beforeClose = function (args) {
console.log(this.cancel);//Here cancel is undefined!!!!! why???
args.cancel = this.cancel;//if I replace by true, It works perfectly
this.cancel = false;
}
}

Thanks in advance for help.

JMEL.

Nevitha Ravi [Syncfusion]
Replied On April 24, 2019 07:15 AM UTC

Hi JMEL Becha, 

Greetings from Syncfusion Support. 

We have prepared a sample to prevent the closing of editor window if the subject of the event is New for your reference which can be viewed from the following link.  In the shared code, this.cancel is undefined as here dialog instance is available in ‘this’. So we have stored it in separate variable in actionBegin and assign that variable in beforeClose event. 

onActionBegin(args: ActionEventArgs): void { 
    if (args.requestType === 'eventCreate' || args.requestType === 'eventChange') { 
      var subject = (args.requestType === 'eventCreate') ? args.data[0].Subject : (args.data as any).Subject; 
      if (subject == 'New') { 
        args.cancel = true; 
        this.cancel = true; 
        let val = this.cancel; 
        this.scheduleObj.eventWindow.dialogObject.beforeClose = function (args) { 
          args.cancel = val; 
          alert("Don't Close the Appointment Window"); 
        } 
        this.cancel = false; 
      } 
    } 
  } 

Please try the sample at you end and let us know if you need any further assistance. 

Regards, 
Nevitha. 


JMEL Becha
Replied On April 24, 2019 10:14 AM UTC

Great !!
It Works perfectly.

Thanks a lot.

JMEL.

Nevitha Ravi [Syncfusion]
Replied On April 24, 2019 12:59 PM UTC

Hi JMEL, 
  
Thanks for your update. 
  
We are glad that your requirement has been fulfilled. 
  
Regards, 
Nevitha 


Parthkumar Kakadiya
Replied On January 21, 2020 04:08 PM UTC

Hi,

In this solution I am getting strange problem.

If i give subject 'New' at first time, I am getting alert with the message. which is correct .







Now if i type valid string at subject apart from 'New', I am still getting the alert. I am not able to close editor window as well.