Agent-readable demo data
- Title
- Disabled Cells (JavaScript Event Calendar) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Read more about disabled cells.
Inline demo script 1
const dp = new DayPilot.Calendar("dp", {
startDate: DayPilot.Date.today(),
viewType: "Week",
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
});
dp.message("Created");
},
onBeforeCellRender: args => {
if (args.cell.start.getDatePart() <= DayPilot.Date.today()) {
args.cell.disabled = true;
args.cell.backColor = "#eee";
}
}
});
dp.init();
const app = {
init() {
this.loadEventData();
},
loadEventData() {
const events = [
{
start: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(12),
end: DayPilot.Date.today().firstDayOfWeek().addDays(1).addHours(15),
id: DayPilot.guid(),
text: "Special event"
}
];
dp.update({events});
}
};
app.init();