Agent-readable demo data
- Title
- Highlighting Unavailable Cells (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Read more about highlighting unavailable cells
[doc.daypilot.org].
Inline demo script 1
const dp = new DayPilot.Scheduler("dp", {
startDate: "2026-01-01",
days: 365,
scale: "Day",
timeHeaders: [
{groupBy: "Month", format: "MMM yyyy"},
{groupBy: "Cell", format: "d"}
],
treeEnabled: true,
treePreventParentUsage: true,
resources: [
{
name: "Locations", id: "G1", expanded: true, children: [
{
name: "Room 1", id: "A", unavailable: [
{start: "2026-09-05", end: "2026-09-08"},
{start: "2026-09-13", end: "2026-09-15"}
]
},
{name: "Room 2", id: "B"},
{name: "Room 3", id: "C"},
{name: "Room 4", id: "D"}
]
},
{
name: "People", id: "G2", expanded: true, children: [
{name: "Person 1", id: "E"},
{name: "Person 2", id: "F"},
{name: "Person 3", id: "G"},
{name: "Person 4", id: "H"}
]
},
{
name: "Tools", id: "G3", expanded: false, children: [
{name: "Tool 1", id: "I"},
{name: "Tool 2", id: "J"},
{name: "Tool 3", id: "K"},
{name: "Tool 4", id: "L"}
]
},
],
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");
},
onBeforeCellRender: args => {
const row = dp.rows.find(args.cell.resource);
const unavailable = row.data.unavailable;
if (!unavailable) {
return;
}
const matches = unavailable.some(range => {
const start = new DayPilot.Date(range.start);
const end = new DayPilot.Date(range.end).addDays(1);
return DayPilot.Util.overlaps(start, end, args.cell.start, args.cell.end);
});
if (matches) {
args.cell.disabled = true;
args.cell.areas = [
{
top: 0,
right: 0,
bottom: 0,
left: 0,
padding: 5,
fontColor: "#666",
backColor: "#f9cb9c",
symbol: "../icons/daypilot.svg#x-2"
}
];
}
}
});
dp.init();
dp.scrollTo("2026-09-01");