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

Disable previous Dates on schedule calendar of react js 2

Thread ID:

Created:

Updated:

Platform:

Replies:

141864 Jan 8,2019 09:00 PM UTC Jan 11,2019 09:41 AM UTC ReactJS 3
loading
Tags: Scheduler
Pavan Kumar
Asked On January 8, 2019 09:00 PM UTC

Hello,

I'm currently using react js 2 scheduler calendar, Could you please let me know how to disable previous dates of schedule calendar.

Karthigeyan Krishnamurthi [Syncfusion]
Replied On January 9, 2019 09:34 AM UTC

Hi Pavan, 
 
Thank you for contacting Syncfusion support. 
 
We have prepared the below sample to prevent the Scheduler from navigating back from February 15, 2019.  
 
actionBegin={this.onActionbegin.bind(this)} 
 
onActionbegin(args) { 
    if (args.requestType == "dateNavigate") { 
      if (this.scheduleObj.selectedDate <= this.date) { 
        args.cancel = (args.event.target.classList.contains('e-icon-prev')); 
      } 
    } 
  } 
 
Note: When the above highlighted condition is removed in the sample then no back navigation will work in Scheduler. 
 
Regards, 
Karthigeyan 


Pavan Kumar
Replied On January 9, 2019 04:31 PM UTC

Hi Karthigeyan,

Thanks for the reply, however reply covers only partial part of the question. Could please help me out with the below

1. Disable navigating back 
2. Disable cells of past days (like greying out cells).
3. No event or popup on clicking disabled/past days.
4. Disable past days on dropdown calendar on  top left navigation.  Attached Image.
 
Thanks! Pavan



Attachment: Screen_Shot_20190109_at_10.24.56_AM_fe13c543.zip

Karthigeyan Krishnamurthi [Syncfusion]
Replied On January 11, 2019 09:41 AM UTC

 
Thanks for your update. 
 
We have prepared the below sample to make the past cells (cells before system current date) as read-only using Scheduler events. 
 
<ScheduleComponent ref={schedule => this.scheduleObj = schedule} width='100%' height='650px' ref={t => this.scheduleObj = t} eventSettings={{ dataSource: this.data }} renderCell={this.onRenderCell.bind(this)} popupOpen={this.onPopupOpen.bind(this)} actionBegin={this.onActionBegin.bind(this)} actionComplete={this.onActionComplete.bind(this)}> 
            <Inject services={[Day, Week, WorkWeek, Month, Agenda, Resize, DragAndDrop]} /> 
</ScheduleComponent> 
 
onPopupOpen(args) { 
    if (args.data.name === "cellClick") { 
      if ((args.data.startTime) < new Date(new Date().setHours(0, 0, 0, 0))) { 
        args.cancel = true; 
      } 
    } else { 
      if ((args.data.StartTime) < new Date(new Date().setHours(0, 0, 0, 0))) { 
        args.cancel = true; 
      } 
    } 
  } 
  onRenderCell(args) { 
    if (args.date < new Date(new Date().setHours(0, 0, 0, 0))) { 
      args.element.classList.add('e-disableCell'); 
    } 
 
  } 
  onActionBegin(args) { 
    if (args.requestType === "eventChange") { 
      if ((args.data.StartTime) < new Date(new Date().setHours(0, 0, 0, 0))) { 
        args.cancel = true; 
      } 
    } 
    if (args.requestType === "eventCreate") { 
      for (var i = 0; i < args.data.length; i++) { 
        if ((args.data[i].StartTime) < new Date(new Date().setHours(0, 0, 0, 0))) { 
          args.cancel = true; 
        } 
      } 
    } 
  } 
  onActionComplete(args) { 
    if (args.requestType === "toolBarItemRendered") { 
      this.scheduleObj.element.querySelectorAll('.e-schedule-toolbar .e-date-range')[0].click(); 
      this.scheduleObj.element.querySelectorAll('.e-calendar')[0].ej2_instances[0].min = new Date(); 
      this.scheduleObj.element.querySelectorAll('.e-schedule-toolbar .e-date-range')[0].click(); 
    } 
  } 
 
 
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.

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

Live Chat Icon For mobile
Live Chat Icon