
In the JavaScript Calendar, you can specify the business hours range using the following properties:
The business hours settings affect the following behavior:
The calendar control height when the heightSpec property is set to
"BusinessHours"or"BusinessHoursNoScroll"Background cell color
Generated-axis filtering with showNonBusiness and working-time moving with eventMoveSkipNonBusiness in JavaScript Pro.
The background cell color can be overridden using the onBeforeCellRender event handler.
To hide the non-business hours, you can specify the displayed hour range using dayBeginsHour and dayEndsHour properties (see also overnight scheduling).
To omit non-business intervals inside a multi-day resource timeline, use Hiding Non-Business Time. This can remove nights between working days and weekend rows. It is independent of the Calendar's viewport height or initial scroll position.
Weekends
businessWeekends controls whether Saturday and Sunday are classified as business days. This classification does not itself hide date columns.
You can show/hide weekends by selecting the ViewType:
"WorkWeek" (hides weekend days)
"Week" (shows weekends days)
CSS
Business cells (defined as Monday-Friday, between BusinessBeginsHour and BusinessEndsHour) are now marked with_cell_business class in CssOnly mode.
Styling business cells in now supported in the theme designer as well.
See also:
JavaScript
const calendar = new DayPilot.Calendar("dp", {
businessBeginsHour: 8,
businessEndsHour: 18,
businessWeekends: false
});
calendar.init();Angular
Add the configuration to an existing Calendar component.
<daypilot-calendar [config]="config"></daypilot-calendar>import {DayPilot} from "daypilot-pro-angular";
config: DayPilot.CalendarConfig = {
businessBeginsHour: 8,
businessEndsHour: 18,
businessWeekends: false
};React
import {DayPilot, DayPilotCalendar} from "daypilot-pro-react";
<DayPilotCalendar
businessBeginsHour={8}
businessEndsHour={18}
businessWeekends={false}
/>Vue
<script setup lang="ts">
import {DayPilot, DayPilotCalendar} from "daypilot-pro-vue";
</script>
<template>
<DayPilotCalendar
:businessBeginsHour="8"
:businessEndsHour="18"
:businessWeekends="false"
/>
</template>ASP.NET WebForms

You can define custom time cell colors using BeforeCellRender event:
protected void DayPilotCalendar1_BeforeCellRender(object sender, BeforeCellRenderEventArgs e)
{
if (e.Start.Hour >= 9 && e.Start.Hour < 12)
e.BackgroundColor = "#FFF2CC"; // shift #1
else if (e.Start.Hour >= 12 && e.Start.Hour < 15)
e.BackgroundColor = "#FFD9CC"; // shift #2
else if (e.Start.Hour >= 15 && e.Start.Hour < 18)
e.BackgroundColor = "#F2FFCC"; // shift #3
}Turning Saturday and Sunday into business days:
protected void DayPilotCalendar1_BeforeCellRender(object sender, BeforeCellRenderEventArgs e)
{
if ((e.Start.DayOfWeek == DayOfWeek.Saturday || e.Start.DayOfWeek == DayOfWeek.Sunday)
|| (e.Start.Hour >= 9 && e.Start.Hour < 18))
{
e.IsBusiness = true;
}
}You can also change just the IsBusiness property and you will get the color automatically:
protected void DayPilotCalendar1_BeforeCellRender(object sender, BeforeCellRenderEventArgs e)
{
if (e.Start.Hour >= 10 && e.Start.Hour < 12)
e.IsBusiness = true;
else if (e.Start.Hour >= 14 && e.Start.Hour < 16)
e.IsBusiness = true;
else
e.IsBusiness = false;
}See Also
ASP.NET MVC
Turning Saturday and Sunday into business days:
protected override void OnBeforeCellRender(BeforeCellRenderArgs e)
{
if ((e.Start.DayOfWeek == DayOfWeek.Saturday || e.Start.DayOfWeek == DayOfWeek.Sunday)
|| (e.Start.Hour >= 9 && e.Start.Hour < 18))
{
e.IsBusiness = true;
}
}
Availability
Availability of this feature in DayPilot editions:
| Product | Lite | Pro |
|---|---|---|
| DayPilot for JavaScript | ||
| DayPilot for ASP.NET WebForms | ||
| DayPilot for ASP.NET MVC | ||
| DayPilot for Java |
DayPilot