Agent-readable demo data

Title
Hiding Non-Business Hours (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
Tree
DayPilot JavaScript Demo
Catalog root
Default
Description
It is possible to hide non-business hours from the Scheduler timeline. The definition of non-business hours is automatically resolved, either at the hour level (e.g., 9 AM - 6 PM) or the day level (e.g., work week), depending on the chosen scale. Read more about hiding non-business hours.

Inline demo script 1

const scheduler = new DayPilot.Scheduler("scheduler", {
            startDate: "2026-01-01",
            days: 62,
            cellWidth: 50,
            scale: "Hour",
            timeHeaders: [
                {groupBy: "Month", format: "MMMM yyyy"},
                {groupBy: "Day", format: "dddd d"},
                {groupBy: "Hour"}
            ],
            treeEnabled: true,
            resources: [
                {name: "Room A", id: "A"},
                {name: "Room B", id: "B"},
                {name: "Room C", id: "C"},
                {name: "Room D", id: "D"},
                {name: "Room E", id: "E"},
                {name: "Room F", id: "F"},
                {name: "Room G", id: "G"},
                {name: "Room H", id: "H"},
                {name: "Room I", id: "I"},
                {name: "Room J", id: "J"},
                {name: "Room K", id: "K"}
            ],
            onTimeRangeSelected: async args => {
                const modal = await DayPilot.Modal.prompt("New event name:", "Event");
                scheduler.clearSelection();
                if (modal.canceled) {
                    return;
                }
                scheduler.events.add({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: modal.result
                });
                scheduler.message("Created");
            },
            showNonBusiness: false,
            // showNonBusinessForceHours: true,
            businessBeginsHour: 9,
            businessEndsHour: 18,
            timeRangeSelectingStartEndFormat: "h:mm tt MMMM d, yyyy",
            height: 250,
        });
        scheduler.init();

        const app = {
            timeHeaders: {
                Hour: [
                    {groupBy: "Month", format: "MMMM yyyy"},
                    {groupBy: "Day", format: "d"},
                    {groupBy: "Hour"}
                ],
                Day: [
                    {groupBy: "Month", format: "MMMM yyyy"},
                    {groupBy: "Day", format: "d"}
                ]
            },
            init() {
                this.addEventHandlers();
            },
            addEventHandlers() {
                document.querySelectorAll("input[type=radio]").forEach(function(el) {
                    el.addEventListener("change", function(ev) {
                        const val = document.querySelector("input[type=radio]:checked").value;

                        scheduler.scale = val;
                        scheduler.timeHeaders = app.timeHeaders[val];
                        scheduler.update();
                    });
                });
            },
        };
        app.init();