Agent-readable demo data
- Title
- JavaScript Scheduler | DayPilot Lite for JavaScript Sandbox
- Tree
- DayPilot JavaScript Sandbox
- Catalog root
- Lite
- Description
- Customize the component using Scheduler UI Builder
and download a ready-to-run project.
Read more about the JavaScript scheduler.
Inline demo script 1
const dp = new DayPilot.Scheduler("dp", {
startDate: "2026-09-01",
days: 365,
scale: "Day",
timeHeaders: [
{groupBy: "Month", format: "MMMM yyyy"},
{groupBy: "Day", format: "d"}
],
heightSpec: "Max",
height: 400,
rowMarginTop: 2,
rowMarginBottom: 2,
contextMenu: new DayPilot.Menu({
items: [
{
text: "Edit",
onClick: async (args) => {
const result = await app.editEvent(args.source.data);
if (!result) {
return;
}
dp.events.update(result);
}
},
{
text: "-"
},
{
text: "Delete",
onClick: (args) => {
dp.events.remove(args.source);
}
},
]
}),
onTimeRangeSelected: async (args) => {
const data = {
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: "New event"
};
const result = await app.editEvent(data);
dp.clearSelection();
if (!result) {
return;
}
dp.events.add(result);
},
onEventClick: async (args) => {
const result = await app.editEvent(args.e.data);
if (!result) {
return;
}
dp.events.update(result);
},
onBeforeEventRender: args => {
args.data.areas = [
{
right: 2,
top: "calc(50% - 9px)",
width: 18,
height: 18,
style: "cursor:pointer;",
backColor: "#cccccc66",
borderRadius: "50%",
padding: 2,
fontColor: "#333333",
symbol: "../icons/daypilot.svg#threedots-h",
action: "ContextMenu",
toolTip: "Menu"
}
];
},
});
dp.init();
dp.scrollTo("2026-09-01");
const app = {
barColor(i) {
const colors = ["#3c78d8", "#6aa84f", "#f1c232", "#cc0000"];
return colors[i % 4];
},
barBackColor(i) {
const colors = ["#a4c2f4", "#b6d7a8", "#ffe599", "#ea9999"];
return colors[i % 4];
},
async editEvent(data) {
const form = [
{ name: "Text", id: "text"},
{ name: "Start", id: "start", type: "datetime", disabled: true },
{ name: "End", id: "end", type: "datetime", disabled: true },
{ name: "Resource", id: "resource", options: dp.resources}
];
const modal = await DayPilot.Modal.form(form, data);
if (modal.canceled) {
return null;
}
return modal.result;
},
loadData() {
const resources = [
{name: "Room 1", id: "A"},
{name: "Room 2", id: "B"},
{name: "Room 3", id: "C"},
{name: "Room 4", id: "D"},
{name: "Person 1", id: "E"},
{name: "Person 2", id: "F"},
{name: "Person 3", id: "G"},
{name: "Person 4", id: "H"},
{name: "Tool 1", id: "I"},
{name: "Tool 2", id: "J"},
{name: "Tool 3", id: "K"},
{name: "Tool 4", id: "L"}
];
const events = [];
for (let i = 0; i < 12; 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 e = {
start: new DayPilot.Date("2026-09-05T12:00:00").addDays(start),
end: new DayPilot.Date("2026-09-05T12:00:00").addDays(start).addDays(durationDays).addHours(duration),
id: i + 1,
resource: String.fromCharCode(65 + i),
text: "Event " + (i + 1),
barColor: app.barColor(i),
barBackColor: app.barBackColor(i)
};
events.push(e);
}
dp.update({resources, events});
},
};
app.loadData();