Select a row row by clicking on the header. Select multiple rows using Ctrl + click
or Shift + click. Read more about
row selecting
[doc.daypilot.org].
Agent-readable demo data
- Title
- Row Selecting (JavaScript Scheduler) | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- Select a row row by clicking on the header. Select multiple rows using Ctrl + click
or Shift + click. Read more about row selecting
[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: "MMMM yyyy"},
{groupBy: "Cell", format: "d"}
],
treeEnabled: true,
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"},
{name: "Room G", id: "G"},
{name: "Room H", id: "H"},
{name: "Room I", id: "I"},
{name: "Room J", id: "J"},
{name: "Room K", id: "K"},
],
onTimeRangeSelected: async (args) => {
const {result} = await DayPilot.Modal.prompt("New event name:", "Event");
dp.clearSelection();
if (!result) return;
const e = new DayPilot.Event({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: result
});
dp.events.add(e);
dp.message("Created");
},
rowClickHandling: "Select",
onRowSelect: (args) => {
if (window.console) {
console.log(args.row.toJSON());
}
},
onRowSelected: (args) => {
const msg = "This row was " + (args.selected ? "" : "de") + "selected: " + args.row.name;
dp.message(msg);
if (window.console) {
console.log(dp.rows.selection.get().length);
}
},
selectedRows: ["A"],
height: 300,
});
dp.init();
dp.scrollTo("2026-03-25");
const app = {
elements: {
add: document.querySelector('#add'),
clear: document.querySelector('#clear'),
},
init() {
this.addEventHandlers();
this.loadEventData();
},
addEventHandlers() {
this.elements.add.addEventListener('click', (ev) => {
ev.preventDefault();
// dp.rows.selection.add("B");
dp.rows.selection.add(dp.rows.find('B'));
});
this.elements.clear.addEventListener('click', (ev) => {
ev.preventDefault();
dp.rows.selection.clear();
});
},
loadEventData() {
// generate and load events
const events = [];
for (let i = 0; i < 15; i++) {
const duration = Math.floor(Math.random() * 6) + 1; // 1 to 6
const durationDays = Math.floor(Math.random() * 6); // 0 to 5
const start = Math.floor(Math.random() * 6) + 2; // 2 to 7
events.push({
start: new DayPilot.Date("2026-03-25T00:00:00").addDays(start),
end: new DayPilot.Date("2026-03-25T12:00:00").addDays(start).addDays(durationDays).addHours(duration),
id: DayPilot.guid(),
resource: String.fromCharCode(65 + i),
text: "Event"
});
}
dp.update({events});
}
};
app.init();