Edit the row text by clicking on the header. Read more about
row editing [doc.daypilot.org].
Agent-readable demo data
- Title
- Row Editing (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Edit the row text by clicking on the header. Read more about row editing [doc.daypilot.org].
Inline demo script 1
const dp = new DayPilot.Scheduler("dp", {
startDate: DayPilot.Date.today().firstDayOfYear(),
days: DayPilot.Date.today().daysInYear(),
scale: "Day",
timeHeaders: [
{groupBy: "Month", format: "MMMM yyyy"},
{groupBy: "Cell", format: "d"}
],
rowHeaderColumns: [
{text: "Name"},
{text: "Capacity", display: "capacity"},
],
treeEnabled: true,
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: name
});
dp.message("Created");
},
rowClickHandling: "Edit",
onRowEdit: (args) => {
if (args.canceled) {
console.log("User-canceled.");
return;
}
},
onRowEdited: (args) => {
dp.message("Row text changed to " + args.newText);
}
});
dp.init();
const app = {
loadEventsAndResources() {
const resources = [
{name: "Room A", id: "A", capacity: 10},
{name: "Room B", id: "B", capacity: 20},
{name: "Room C", id: "C", capacity: 10},
{name: "Room D", id: "D", capacity: 10},
{name: "Room E", id: "E", capacity: 30},
{name: "Room F", id: "F", capacity: 10},
{name: "Room G", id: "G", capacity: 40},
{name: "Room H", id: "H", capacity: 10},
{name: "Room I", id: "I", capacity: 20},
{name: "Room J", id: "J", capacity: 30},
{name: "Room K", id: "K", capacity: 10},
];
// generate and load events
const events = [];
const first = new DayPilot.Date(dp.startDate);
for (var i = 0; i < 15; i++) {
var duration = Math.floor(Math.random() * 6) + 1; // 1 to 6
var durationDays = Math.floor(Math.random() * 6); // 0 to 5
var start = Math.floor(Math.random() * 6) + 2; // 2 to 7
var res = Math.floor(Math.random() * 6); // 0 to 5
events.push({
start: first.addDays(start),
end: first.addDays(start).addDays(durationDays).addHours(duration),
id: DayPilot.guid(),
resource: String.fromCharCode(65 + i),
text: "Event"
});
}
dp.update({
events,
resources
});
},
init() {
app.loadEventsAndResources();
}
};
app.init();