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: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Prevent new appointment window from closing after save click

Thread ID:

Created:

Updated:

Platform:

Replies:

141540 Dec 17,2018 12:26 PM UTC Dec 31,2018 06:20 AM UTC ASP.NET Core - EJ 2 5
loading
Tags: Scheduler
Gregory Perozzo
Asked On December 17, 2018 12:26 PM UTC

Hello,

I need to check some information of the new appointment window in my database when the save button is clicked.

After that, if there's something that can block that appointment, I need to show a message to the user and don't close the appointment window.

I tried using the onActionBegin(args) function with no success.

How can I do that?

Thank you very much!



Karthigeyan Krishnamurthi [Syncfusion]
Replied On December 18, 2018 04:49 AM UTC

 
Thank you for contacting Syncfusion support. 
 
We have prepared the below sample to prevent the event window from closing after the insert action is prevented. In the below sample, when an event is saved with the subject as New, then save action is prevent by setting args.cancel to true with in actionbegin event. 
 
<ejs-schedule id="schedule" height="100%" actionbegin="onActionBegin" databound="onDataBound"> 
    <e-schedule-eventsettings> 
        <e-data-manager url="/Home/LoadData" crudurl="Home/UpdateData" adaptor="UrlAdaptor" crossdomain="true"> 
        </e-data-manager> 
    </e-schedule-eventsettings> 
</ejs-schedule> 
 
var flag = false; 
function onActionBegin(args) { 
    if (args.requestType === 'eventCreate' || args.requestType === 'eventChange') { 
        var subject = (args.requestType === 'eventCreate') ? args.data[0].Subject : (args.data).Subject; 
        if (subject == 'New') { 
            args.cancel = true; 
            flag = true; 
        } 
 
    } 
} 
function onDataBound() { 
    var scheduleObj = document.getElementById('schedule').ej2_instances[0]; 
    scheduleObj.eventWindow.dialogObject.beforeClose = function (args) { 
        args.cancel = flag; 
        flag = false; 
        alert("Don't Close the Appointment Window"); 
    } 
} 
 
Regards, 
Karthigeyan 


Gregory Perozzo
Replied On December 18, 2018 07:38 PM UTC

Hello Karthigeyan,

That's exactly what I needed! Perfect.

I was wondering if it's possible to manually activate a field validation by code like this:



Example: if the user type an wrong date or time, I need to validate it. What's the best way of doing it? Today I only validate the field length by doing this:

var DateValidation = new Dictionary<string, object>() { { "required", true }, { "minLength", 16 }, { "maxLength", 16 } };

But if the user type a date and time like this it works because of the length, but the date and time are wrong:



How can I achieve it?




Karthigeyan Krishnamurthi [Syncfusion]
Replied On December 19, 2018 12:28 PM UTC

Hi Gregory, 
 
Thanks for your update. 
 
By default, in Datepicker control, we can allow only valid date value using strictMode API and for the same we have prepared the below sample. 
 
var startElement = args.element.querySelector('#StartTime'); 
if (!startElement.classList.contains('e-datetimepicker')) { 
    new ej.calendars.DateTimePicker({ strictMode:true , value: new Date(startElement.value) || new Date() }, startElement); 
} 
var endElement = args.element.querySelector('#EndTime'); 
if (!endElement.classList.contains('e-datetimepicker')) { 
    new ej.calendars.DateTimePicker({ strictMode: true,  value: new Date(endElement.value) || new Date() }, endElement); 
} 
 
Note: strictMode will automatically correct the date format when the date picker lost its focus.   
 
Regards, 
Karthigeyan 
 
 


Gregory Perozzo
Replied On December 26, 2018 07:36 PM UTC

Hello Karthigeyan,

That's just perfect. Again, exactly what I needed. Thank you very much!

Sorry for the late response.

Have a nice day and wish you a happy new year!

Nevitha Ravi [Syncfusion]
Replied On December 31, 2018 06:20 AM UTC

Hi Gregory, 

Thanks for your update and we are glad that our provided solution fulfilled your requirement.  

We wish you too a very happy and fantastic new year. 

Regards, 
Nevitha. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;