The onTimeRangeSelect event handler fires when the user completes a date/time range selection using drag and drop in the JavaScript Scheduler component, before the default action configured by timeRangeSelectedHandling is performed.
DayPilot.Scheduler.onTimeRangeSelect(args)args.start (DayPilot.Date) - start of the selection
args.end (DayPilot.Date) - end of the selection
args.multirange (array) - existing selections when multi-range selection is enabled; each item includes start, end, and resource
args.origin ("click" | "drag" | "api" | "keyboard") - origin of the event; "click" is used if the user clicks a grid cell without dragging; available since 2023.4.5803
args.resource (string | number) - selection resource id
args.preventDefault() - cancels the default action and prevents DayPilot.Scheduler.onTimeRangeSelected from firing
While the user is changing the selection, the component fires DayPilot.Scheduler.onTimeRangeSelecting whenever the selected range changes.
Not available in api=1 mode.
JavaScript
const dp = new DayPilot.Scheduler("dp", {
timeRangeSelectedHandling: "Enabled",
onTimeRangeSelect: (args) => {
if (args.start.getDayOfWeek() === 0 || args.start.getDayOfWeek() === 6) {
args.preventDefault();
}
},
// ...
});
dp.init();Angular
<daypilot-scheduler [config]="config"></daypilot-scheduler>config: DayPilot.SchedulerConfig = {
timeRangeSelectedHandling: "Enabled",
onTimeRangeSelect: (args) => {
if (args.start.getDayOfWeek() === 0 || args.start.getDayOfWeek() === 6) {
args.preventDefault();
}
},
// ...
};React
<DayPilotScheduler
timeRangeSelectedHandling="Enabled"
onTimeRangeSelect={onTimeRangeSelect}
{/* ... */}
/>const onTimeRangeSelect = (args) => {
if (args.start.getDayOfWeek() === 0 || args.start.getDayOfWeek() === 6) {
args.preventDefault();
}
};Vue
<DayPilotScheduler
timeRangeSelectedHandling="Enabled"
@timeRangeSelect="onTimeRangeSelect"
<!-- ... -->
/>const onTimeRangeSelect = (args) => {
if (args.start.getDayOfWeek() === 0 || args.start.getDayOfWeek() === 6) {
args.preventDefault();
}
};Event Creation [doc.daypilot.org]
DayPilot.Scheduler.onTimeRangeSelected
DayPilot.Scheduler.onTimeRangeSelecting
DayPilot.Scheduler.timeRangeSelectedHandling
Availability of this API item in DayPilot editions:
| Lite | Pro | |
|---|---|---|
| DayPilot for JavaScript |
Lite args missing: multirange, origin