The onTimeRangeSelecting event handler fires during time range selecting in the JavaScript Calendar component, on every target position change. You can use it to control the selection shadow appearance and implement custom business rules.
Declaration
DayPilot.Calendar.onTimeRangeSelecting(args)Parameters
args.anchor(DayPilot.Date) - fixed-edge timestamp of the selection, the one not being resized (since 2023.1.5536)args.e(DayPilot.Event) - associated item reference (read-only)args.start(DayPilot.Date) - current shadow start; since 2023.1.5536 the value can be modifiedargs.end(DayPilot.Date) - current shadow end; since 2023.1.5536 the value can be modifiedargs.duration(DayPilot.Duration) - current selection lengthargs.resource(string | number) - current resource ID (read-only)args.html(string) - shadow HTMLargs.cssClass(string) - shadow CSS classargs.allowed(boolean) - enables or disables selection at the current target positionargs.top.width(number) - width of the top text; usenullfor automatic widthargs.top.space(number) - distance of the top text from the shadow in pixelsargs.top.html(string) - top HTMLargs.top.enabled(boolean) - enables or disables the top textargs.bottom.width(number) - width of the bottom text; usenullfor automatic widthargs.bottom.space(number) - distance of the bottom text from the shadow in pixelsargs.bottom.html(string) - bottom HTMLargs.bottom.enabled(boolean) - enables or disables the bottom textargs.alt(boolean) - Alt key pressed status (since 2026.2.6913)args.ctrl(boolean) - Ctrl key pressed status (since 2026.2.6913)args.shift(boolean) - Shift key pressed status (since 2026.2.6913)args.meta(boolean) - Meta key pressed status (since 2026.2.6913)
Notes
The handler runs continuously while the user changes the selection target. You can update args.start, args.end, args.html, args.cssClass, and the top or bottom labels to customize the live preview, or set args.allowed to false to reject the current target position.
Examples
JavaScript
const calendar = new DayPilot.Calendar("dp", {
onTimeRangeSelecting: (args) => {
args.top.enabled = true;
args.top.html = "Duration: " + args.duration.totalHours() + " hours";
},
// ...
});
calendar.init();Angular
<daypilot-calendar [config]="config"></daypilot-calendar>config: DayPilot.CalendarConfig = {
onTimeRangeSelecting: (args) => {
args.top.enabled = true;
args.top.html = "Duration: " + args.duration.totalHours() + " hours";
},
// ...
};React
<DayPilotCalendar
onTimeRangeSelecting={onTimeRangeSelecting}
{/* ... */}
/>const onTimeRangeSelecting = (args) => {
args.top.enabled = true;
args.top.html = "Duration: " + args.duration.totalHours() + " hours";
};Vue
<DayPilotCalendar
@timeRangeSelecting="onTimeRangeSelecting"
<!-- ... -->
/>const onTimeRangeSelecting = (args) => {
args.top.enabled = true;
args.top.html = "Duration: " + args.duration.totalHours() + " hours";
};See Also
Time Range Selecting [doc.daypilot.org]
DayPilot.Calendar.onTimeRangeSelected
Availability
Availability of this API item in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript |
DayPilot