Agent-readable demo data

Title
Time Header (JavaScript Event Calendar) | DayPilot Pro for JavaScript Demo
Tree
DayPilot JavaScript Demo
Catalog root
Default
Description
Read more about the time header cell duration.

Inline demo script 1

const dp = new DayPilot.Calendar("dp", {
            startDate: DayPilot.Date.today(),
            viewType: "Week",
            businessBeginsHour: 9,
            businessEndsHour: 13,
            timeHeaderCellDuration: 15,
            cellDuration: 15,
            hourWidth: 100,
            cellHeight: 35,
            onTimeRangeSelected: async args => {
                const modal = await DayPilot.Modal.prompt("New event name:", "Event");
                if (modal.canceled) return;
                dp.events.add({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: modal.result
                });
                dp.clearSelection();
                dp.message("Created");
            },
            onBeforeTimeHeaderRender: args => {
                const hour = DayPilot.Date.today().addTime(args.header.time);
                args.header.html = hour.toString("h:mm tt");
                args.header.cssClass = "hourheader";
            },
        });

        dp.init();



        const app = {
            init() {
                this.loadEventData();
            },
            loadEventData() {
                const events = [
                    {
                        start: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(11),
                        end: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(14),
                        id: DayPilot.guid(),
                        text: "Event 1"
                    },
                    {
                        start: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(15),
                        end: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(17),
                        id: DayPilot.guid(),
                        text: "Event 2"
                    },
                ];
                dp.update({events});
            }
        };
        app.init();