Agent-readable demo data

Title
Frozen Rows (JavaScript Scheduler) | DayPilot Pro for JavaScript Sandbox
Tree
DayPilot JavaScript Sandbox
Catalog root
Default
Description
The Scheduler can freeze selected rows at the top and/or bottom of the viewport. Read more about frozen rows.

Inline demo script 1

const dp = new DayPilot.Scheduler("dp", {
            startDate: "2026-01-01",
            days: 365,
            scale: "Day",
            timeHeaders: [
                {groupBy: "Month", format: "MMMM yyyy"},
                {groupBy: "Day", format: "d"}
            ],
            rowHeaderColumns: [
                {title: "Name", display: "name"},
                {title: "Id", display: "id"},
            ],
            treeEnabled: true,
            resources: [
                {name: "Frozen 1", id: "frozen1", frozen: "top"},
                {name: "Frozen 2", id: "frozen2", frozen: "top"},
                {name: "Frozen 3", id: "frozen3", frozen: "bottom"},
                {
                    name: "Locations", id: "G1", expanded: true, children: [
                        {name: "Room 1", id: "A"},
                        {name: "Room 2", id: "B"},
                        {name: "Room 3", id: "C"},
                        {name: "Room 4", id: "D"}
                    ]
                },
                {
                    name: "People", id: "G2", expanded: true, children: [
                        {name: "Person 1", id: "E"},
                        {name: "Person 2", id: "F"},
                        {name: "Person 3", id: "G"},
                        {name: "Person 4", id: "H"}
                    ]
                },
                {
                    name: "Tools", id: "G3", expanded: true, children: [
                        {name: "Tool 1", id: "I"},
                        {name: "Tool 2", id: "J"},
                        {name: "Tool 3", id: "K"},
                        {name: "Tool 4", id: "L"}
                    ]
                },
                {
                    name: "Other Resources", id: "G4", expanded: true, children: [
                        {name: "Resource 1", id: "R1"},
                        {name: "Resource 2", id: "R2"},
                        {name: "Resource 3", id: "R3"},
                        {name: "Resource 4", id: "R4"}
                    ]
                },
            ],
            heightSpec: "Max",
            eventMovingStartEndEnabled: true,
            eventResizingStartEndEnabled: true,
            timeRangeSelectingStartEndEnabled: true,
            onTimeRangeSelected: async args => {
                const modal = await DayPilot.Modal.prompt("New event name:", "New Event");
                dp.clearSelection();
                const name = modal.result;
                if (!name) return;
                const e = new DayPilot.Event({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: name
                });

                // dp.rows.find("frozen1").cells.all().invalidate();
                dp.events.add(e);
                dp.message("Created");
            },
            height: 350,
            rowHeaderColumnsMergeParents: false
        });
        dp.init();
        dp.scrollTo("2026-02-01");


        const app = {
            init() {
                this.addEventHandlers();
                this.loadEventData();
            },
            loadEventData() {
                // generate and load events
                const events = [];

                for (let i = 0; i < 15; i++) {
                    const duration = Math.floor(Math.random() * 6) + 1; // 1 to 6
                    const durationDays = Math.floor(Math.random() * 6 + 1); // 1 to 6
                    const start = Math.floor(Math.random() * 6) + 2; // 2 to 7

                    const resId = String.fromCharCode(65 + i);

                    const event = {
                        start: new DayPilot.Date("2026-02-05T12:00:00").addDays(start),
                        end: new DayPilot.Date("2026-02-05T12:00:00").addDays(start).addDays(durationDays).addHours(duration),
                        id: DayPilot.guid(),
                        resource: resId,
                        text: `Event ${i + 1}`,
                        barColor: app.barColor(i),
                        barBackColor: app.barBackColor(i)
                    };

                    events.push(event);
                }

                events.push({
                    start: "2026-02-02",
                    end: "2026-02-10",
                    id: "frozen1",
                    resource: "frozen1",
                    text: "Frozen row event 1"
                });

                events.push({
                    start: "2026-02-03",
                    end: "2026-02-11",
                    id: "frozen2",
                    resource: "frozen1",
                    text: "Frozen row event 2"
                });

                events.push({
                    start: "2026-02-03",
                    end: "2026-02-11",
                    id: "frozen3",
                    resource: "frozen3",
                    text: "Frozen row event 3"
                });

                events.push({
                    start: "2026-02-14",
                    end: "2026-02-16",
                    id: "frozen4",
                    resource: "frozen3",
                    text: "Frozen row event 4"
                });

                dp.update({events});
            },
            barColor(i) {
                const colors = ["#3c78d8", "#6aa84f", "#f1c232", "#cc0000"];
                return colors[i % 4];
            },
            barBackColor(i) {
                const colors = ["#a4c2f4", "#b6d7a8", "#ffe599", "#ea9999"];
                return colors[i % 4];
            },
            addEventHandlers() {
                document.querySelector("#export-button").addEventListener("click", function(ev) {
                    ev.preventDefault();
                    const area = document.querySelector("#area").value;

                    const e = dp.exportAs("svg", {
                        area: area,
                        dateFrom: "2026-02-01",
                        dateTo: "2026-03-01",
                        resourceFrom: "G1",
                        resourceTo: "D"
                    });
                    const element = e.toElement();
                    element.style.height = e.dimensions().height + "px";
                    element.style.width = e.dimensions().width + "px";
                    document.querySelector("#export").innerHTML = "";
                    document.querySelector("#export").appendChild(element);
                });
            }
        };
        app.init();