Agent-readable demo data

Title
Event Inline Editing (JavaScript Scheduler) | DayPilot Pro for JavaScript Sandbox
Tree
DayPilot JavaScript Sandbox
Catalog root
Default
Description
You can edit existing events inline (on click). You can also create new events inline (on a cell click or selecting multiple cells). Read more about inline event editing.

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: "Cell", format: "d"}
            ],
            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"}
            ],
            eventClickHandling: "Edit",
            onTimeRangeSelected: args => {
                const e = new DayPilot.Event({
                    start: args.start,
                    end: args.end,
                    id: DayPilot.guid(),
                    resource: args.resource,
                    text: "",
                    tags: {justCreated: true}
                });
                dp.events.add(e);
                dp.clearSelection();
                dp.events.edit(e);
            },
            onEventEdit: args => {
                if (args.e.tag("justCreated")) {
                    if (args.canceled || args.newText === "") {
                        dp.events.remove(args.e);
                    }
                    args.e.data.tags.justCreated = false;
                }
            }
        });
        dp.init();
        dp.scrollTo("2026-03-25");


        const app = {
            init() {
                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 + 2); // 2 to 7
                    const start = Math.floor(Math.random() * 6) + 2; // 2 to 7

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

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

                    events.push(event);
                }
                dp.update({events});
            }
        };
        app.init();