Agent-readable demo data
- Title
- Open-Source JavaScript Event Calendar | DayPilot Lite for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Lite
- Description
- Note:
Customize the component using Calendar UI Builder
and download a ready-to-run project.
Read more about the JavaScript event calendar.
Inline demo script 1
const dp = new DayPilot.Calendar("dp", {
viewType: "Week",
startDate: "2026-10-12",
headerDateFormat: "dddd",
contextMenu: new DayPilot.Menu({
items: [
{
text: "Show event ID",
onClick: (args) => {
const e = args.source;
DayPilot.Modal.alert(DayPilot.Util.escapeHtml("Event value: " + e.id()));
}
},
{
text: "Show event text",
onClick: (args) => {
const e = args.source;
DayPilot.Modal.alert(DayPilot.Util.escapeHtml("Event text: " + e.text()));
}
},
{
text: "Show event start",
onClick: (args) => {
const e = args.source;
DayPilot.Modal.alert(DayPilot.Util.escapeHtml("Event start: " + e.start()));
}
},
{
text: "Delete",
onClick: (args) => {
dp.events.remove(args.source);
}
}
]
}),
onEventClick: async (args) => {
const colors = [
{ name: "Blue", id: "#3c78d8" },
{ name: "Green", id: "#6aa84f" },
{ name: "Yellow", id: "#f1c232" },
{ name: "Red", id: "#cc0000" },
];
const form = [
{ name: "Text", id: "text" },
{ name: "Start", id: "start", type: "datetime" },
{ name: "End", id: "end", type: "datetime" },
{ name: "Color", id: "barColor", type: "select", options: colors },
];
const modal = await DayPilot.Modal.form(form, args.e.data);
if (modal.canceled) {
return;
}
dp.events.update(modal.result);
},
onTimeRangeSelected: async (args) => {
const form = [
{ name: "Name", id: "text" }
];
const data = {
text: "Event"
};
const modal = await DayPilot.Modal.form(form, data);
dp.clearSelection();
if (modal.canceled) {
return;
}
dp.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
text: modal.result.text,
barColor: "#3c78d8"
});
},
onBeforeEventRender: args => {
args.data.barBackColor = "transparent";
if (!args.data.barColor) {
args.data.barColor = "#333";
}
args.data.areas = [
{
right: 6,
top: 6,
width: 18,
height: 18,
style: "cursor:pointer;",
backColor: "#cccccc66",
borderRadius: "50%",
padding: 2,
fontColor: "#333333",
verticalAlignment: "center",
horizontalAlignment: "center",
symbol: "../icons/daypilot.svg#threedots-h",
action: "ContextMenu",
toolTip: "Menu"
}
];
},
});
dp.init();
const app = {
init() {
this.loadEvents();
},
loadEvents() {
const events = [
{
start: "2026-10-12T11:00:00",
end: "2026-10-12T14:00:00",
id: 1,
text: "Event 1",
barColor: "#3c78d8"
},
{
start: "2026-10-13T12:00:00",
end: "2026-10-13T15:00:00",
id: 2,
text: "Event 2",
barColor: "#6aa84f"
},
{
start: "2026-10-14T10:00:00",
end: "2026-10-14T15:00:00",
id: 3,
text: "Event 3",
barColor: "#f1c232"
},
{
start: "2026-10-15T12:00:00",
end: "2026-10-15T16:00:00",
id: 4,
text: "Event 4",
barColor: "#cc0000"
},
];
dp.update({ events });
}
};
app.init();