How validate if current cell has Events (Scheduler)?
Asked by Ivan Estrada
4 years ago.
Good day!
This feature exist for Calendar for Asp as IsThereEvent();
There's something similar for scheduler javascript.
Another way is loop my event array and validate the 'Start' property, but I want to know if there is already any function for this.
Grettings from Mexico
Answer posted by Dan Letecky [DayPilot]
4 years ago.
In the JavaScript version, you can use the following methods:
1. To check a time range (for all resources), use the events.forRange() method:
https://api.daypilot.org/daypilot-scheduler-events-forrange/
The following tutorial uses this method to display an availability chart:
https://code.daypilot.org/93064/javascript-scheduler-column-summary
2. To check a specific cell, use the DayPilot.Row.events.forRange() method:
https://api.daypilot.org/daypilot-row-events-forrange/
Comment posted by Ivan Estrada
4 years ago.
Thanks Dan!
dp.events.forRange(date) it works perfectly
But for the current row I can't, i use selection.get()
dp.onTimeRangeSelected = function (args) {
var events = dp.rows.selection.get().events.forRange("2021-09-10T00:00:00");
}
I like add a event if the current cell is empty.
Thanks in advance!!!
Comment posted by Dan Letecky [DayPilot]
4 years ago.
Ivan,
If you just want to disable event overlaps you can use the allowEventOverlap property (https://doc.daypilot.org/scheduler/event-overlaps/):
dp.allowEventOverlap = false;
To find existing events for the current selection in onTimeRangeSelected you can use the following code:
dp.onTimeRangeSelected = function (args) {
var row = dp.rows.find(args.resource);
var events = row.events.forRange(args.start, args.end);
if (events.length > 0) {
console.log("existing events found");
}
};
Comment posted by Ivan Estrada
4 years ago.
Dan!
allowEventOverlap has worked for me, but with the second option I can customize it more.
That you have an excellent day!
Thanks a lot!!!
This question is more than 1 month old and has been closed. Please create a new question if you have anything to add.