Agent-readable demo data
- Title
- Navigator (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Read more about integrating the date navigator [doc.daypilot.org].
Inline demo script 1
const nav = new DayPilot.Navigator("nav", {
showMonths: 3,
selectMode: "Month",
onTimeRangeSelected: args => {
dp.startDate = args.start;
dp.days = args.days;
dp.update();
},
});
nav.init();
const dp = new DayPilot.Scheduler("dp", {
startDate: DayPilot.Date.today().firstDayOfMonth(),
cellGroupBy: "Month",
days: DayPilot.Date.today().daysInMonth(),
scale: "Day",
cellWidthSpec: "Auto",
timeHeaders: [
{groupBy: "Month"},
{groupBy: "Day", format: "d"}
],
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"}
],
onTimeRangeSelected: async args => {
const modal = await DayPilot.Modal.prompt("New event name:", "Event");
dp.clearSelection();
if (modal.canceled) return;
dp.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: modal.result || "Event" // Fallback to "Event" if name is not provided
});
dp.message("Created");
}
});
dp.init();
const app = {
init() {
this.loadEventData();
},
loadEventData() {
const events = [
{
start: DayPilot.Date.today().firstDayOfWeek().addDays(1),
end: DayPilot.Date.today().firstDayOfWeek().addDays(2),
resource: "A",
id: 1,
text: "Reservation 1"
},
{
start: DayPilot.Date.today().firstDayOfWeek().addDays(4),
end: DayPilot.Date.today().firstDayOfWeek().addDays(6),
resource: "A",
id: 2,
text: "Reservation 2"
},
];
dp.update({events});
}
};
app.init();