Disable previous Dates on schedule calendar of react js 2
Hello,
I'm currently using react js 2 scheduler calendar, Could you please let me know how to disable previous dates of schedule calendar.
SIGN IN To post a reply.
3 Replies
KK
Karthigeyan Krishnamurthi
Syncfusion Team
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
PK
Pavan Kumar
January 9, 2019 04:31 PM UTC
Hi Karthigeyan,
Attachment: Screen_Shot_20190109_at_10.24.56_AM_fe13c543.zip
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
KK
Karthigeyan Krishnamurthi
Syncfusion Team
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
SIGN IN To post a reply.
- 3 Replies
- 2 Participants
-
PK Pavan Kumar
- Jan 8, 2019 09:00 PM UTC
- Jan 11, 2019 09:41 AM UTC