Height mode:
Agent-readable demo data
- Title
- Calendar Height (Open-Source JavaScript Event Calendar) | DayPilot Lite for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Lite
- Description
- Note:
Read more about the Calendar height.
Inline demo script 1
const dp = new DayPilot.Calendar("dp", {
viewType: "Week",
startDate: "2022-03-21",
headerDateFormat: "dddd",
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);
},
onBeforeEventRender: args => {
args.data.barBackColor = "transparent";
if (!args.data.barColor) {
args.data.barColor = "#333";
}
},
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"
});
},
onHeaderClick: args => {
console.log("args", args);
},
onEventResize: args => {
console.log("args", args);
}
});
dp.init();
const app = {
elements: {
height: document.querySelector("#height")
},
init() {
this.addEventHandlers();
this.loadEvents();
},
loadEvents() {
const events = [
{
start: "2022-03-21T11:00:00",
end: "2022-03-21T14:00:00",
id: 1,
text: "Event 1",
barColor: "#3c78d8"
},
{
start: "2022-03-22T12:00:00",
end: "2022-03-22T15:00:00",
id: 2,
text: "Event 2",
barColor: "#6aa84f"
},
{
start: "2022-03-23T10:00:00",
end: "2022-03-23T15:00:00",
id: 3,
text: "Event 3",
barColor: "#f1c232"
},
{
start: "2022-03-24T12:00:00",
end: "2022-03-24T16:00:00",
id: 4,
text: "Event 4",
barColor: "#cc0000"
},
];
dp.update({events});
},
addEventHandlers() {
app.elements.height.addEventListener("change", () => {
const heightSpec = app.elements.height.value;
dp.update({heightSpec});
});
}
};
app.init();