Agent-readable demo data
- Title
- Message Bar (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Read more about the message bar [doc.daypilot.org].
Inline demo script 1
const dp = new DayPilot.Scheduler("dp", {
startDate: new DayPilot.Date("2026-01-01"),
cellGroupBy: "Month",
days: new DayPilot.Date("2026-01-01").daysInYear(),
scale: "Day",
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"},
],
onTimeRangeSelected: async args => {
const modal = await DayPilot.Modal.prompt("New event name:", "New Event");
dp.clearSelection();
const name = modal.result;
if (!name) return;
dp.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: name
});
dp.message("Created");
},
height: 300
});
dp.init();
dp.scrollTo("2026-03-01");
const app = {
elements: {
top: document.querySelector('#top'),
bottom: document.querySelector('#bottom')
},
addEventHandlers() {
this.elements.top.addEventListener('click', (ev) => {
ev.preventDefault();
dp.messageBarPosition = 'Top';
dp.message('Message bar moved to the top.');
});
this.elements.bottom.addEventListener('click', (ev) => {
ev.preventDefault();
dp.messageBarPosition = 'Bottom';
dp.message('Message bar moved to the bottom.');
});
},
loadEventData() {
// generate and load events
const events = [];
for (let i = 0; i < 10; i++) {
const duration = Math.floor(Math.random() * 6) + 1; // 1 to 6
const start = Math.floor(Math.random() * 6) - 3; // -3 to 3
const event = {
start: new DayPilot.Date("2026-03-05T00:00:00").addDays(start),
end: new DayPilot.Date("2026-03-05T12:00:00").addDays(start).addDays(duration),
id: DayPilot.guid(),
resource: String.fromCharCode(65 + i),
text: "Event"
};
events.push(event);
}
dp.update({events});
},
init() {
this.addEventHandlers();
this.loadEventData();
}
};
app.init();