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.
Unfortunately, activation email could not send to your email. Please try again.

Schedule MinDate Prevent Display of Past Appointment

Thread ID:

Created:

Updated:

Platform:

Replies:

131823 Jul 28,2017 08:26 AM Aug 1,2017 12:33 AM ASP.NET MVC 3
loading
Tags: Schedule
Charles
Asked On July 28, 2017 08:26 AM

I used Schedule MinDate which is always currentDate to prevent creating or editing appointment of past days but realized it just totally block the display of past appointments.

I want to be able to display or view past appointment but disable creating appointments on past days or editing appointments of past days.

Karthigeyan Krishnamurthi [Syncfusion]
Replied On July 31, 2017 02:43 AM

Hi Charles, 
 
Thank you for contacting Syncfusion support. 
 
We have prepared the sample to disable creating/editing of the past appointments which can be viewed form the below link. 
 
<Code> 
create: "onCreate", 
actionBegin: "onBegin", 
cellClick: "onOpen", 
appointmentWindowOpen: "onOpen", 
appointmentHover: "onHover", 
dragStop: "onAction", 
resizeStop: "onAction", 
actionComplete: "onComplete", 
cellHover: "onCellHover", 
dragStart: "onStart", 
resizeStart: "onStart", 
beforeAppointmentCreate: "OnBeforeAppointmentCreate", 
beforeAppointmentChange: "OnBeforeAppointmentChange", 
 
function OnBeforeAppointmentCreate(args) { 
    if (ej.isNullOrUndefined(args.appointment[0])) 
        app = args.appointment; 
    else 
        app = args.appointment[0]; 
    if (new Date(app.StartTime).setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) 
        args.cancel = true 
} 
function OnBeforeAppointmentChange(args) { 
    if (new Date(args.appointment.StartTime).setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) 
        args.cancel = true 
} 
function onStart(args) { 
    if (new Date(args.appointment.StartTime).setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) 
        args.cancel = true 
} 
function onCellHover(args) { 
    if (new Date(args.currentDate).setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) 
        args.cancel = true 
} 
function onOpen(args) { 
    if (ej.isNullOrUndefined(args.appointment)) { 
        if (args.startTime.setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) 
            args.cancel = true 
    } 
    else { 
        if (new Date(args.appointment.StartTime).setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) 
            args.cancel = true 
    } 
} 
function onCreate() { 
    var scheduleObj = $("#Schedule1").data("ejSchedule"); 
    if (scheduleObj.currentView() == "month") { 
        var monthElements = scheduleObj.element.find(".e-monthcells"); 
        var dayIndex = scheduleObj._dateRender.indexOf(new Date().setHours(0, 0, 0, 0)); 
        for (var a = 0, len = scheduleObj._dateRender.length; a < len; a++) { 
            if (scheduleObj._dateRender[a] < new Date().setHours(0, 0, 0, 0)) 
                monthElements.eq(a).addClass("e-othermonths e-disable"); 
        } 
    } 
    else { 
        var allDayElements = scheduleObj.element.find(".e-alldaycells"); 
        for (var b = 0, len = scheduleObj._dateRender.length; b < len; b++) { 
            if (scheduleObj._dateRender[b] < new Date().setHours(0, 0, 0, 0)) { 
                scheduleObj.element.find(".e-workcellstab tr td:nth-child(" + (b + 1) + ")").addClass("e-disable"); 
                allDayElements.eq(b).addClass("e-disable"); 
            } 
            else { 
                scheduleObj.element.find(".e-workcellstab tr td:nth-child(" + (b + 1) + ")").removeClass("e-disable"); 
                allDayElements.eq(b).removeClass("e-disable"); 
            } 
        } 
    } 
} 
function onComplete(args) { 
    if (args.requestType == "dateNavigate" || args.requestType == "viewNavigate") 
        onCreate(); 
} 
function onBegin(args) { 
    if (args.requestType == "appointmentResize" || args.requestType == "appointmentDrag") { 
        if (args.data.appointment.StartTime.getMonth() != new Date().getMonth()) 
            args.cancel = true 
    } 
} 
function onHover(args) { 
    if (new Date(args.appointment.StartTime).setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) 
        args.cancel = true 
 
} 
function onAction(args) { 
    if (new Date(args.appointment.StartTime).setHours(0, 0, 0, 0) < new Date().setHours(0, 0, 0, 0)) 
        args.cancel = true 
} 
</Code> 
 
Note: In above sample, appointments/cells which are before the system date is disabled. 
 
Regards, 
Karthigeyan 


Charles
Replied On July 31, 2017 10:01 AM

Thanks alot, worked perfectly fine.


Karthigeyan Krishnamurthi [Syncfusion]
Replied On August 1, 2017 12:33 AM

Hi Charles,  
 
We are happy to hear that our solution has fulfilled your requirement. 
 
Regards, 
Karthigeyan 





                                                                                       


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.

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.

;