When dragOutAllowed is true, you can drag an event to another Calendar instance.
Agent-readable demo data
- Title
- JavaScript Event Calendar | DayPilot Pro for JavaScript Demo
- Tree
- DayPilot JavaScript Demo
- Catalog root
- Default
- Description
- When dragOutAllowed is true, you can drag an event to another Calendar instance.
Inline demo script 1
const dp1 = new DayPilot.Calendar("dp1", {
dragOutAllowed: true,
startDate: DayPilot.Date.today(),
viewType: "Week",
showEventStartEnd: false,
scrollLabelsVisible: true,
timeRangeSelectingStartEndEnabled: true,
showCurrentTime: true,
onEventMove: args => {
const target = args.control;
const source = args.e.calendar;
if (target !== source) {
source.events.remove(args.e);
}
},
onEventMoved: (args) => {
dp1.message("Moved: " + args.e.text());
},
onTimeRangeSelected: async (args) => {
const modal = await DayPilot.Modal.prompt("New event name:", "Event");
dp1.clearSelection();
if (modal.canceled) return;
dp1.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: modal.result
});
dp1.message("Created");
},
});
dp1.init();
const dp2 = new DayPilot.Calendar("dp2", {
dragOutAllowed: true,
startDate: DayPilot.Date.today(),
viewType: "Week",
showEventStartEnd: false,
scrollLabelsVisible: true,
timeRangeSelectingStartEndEnabled: true,
showCurrentTime: true,
onEventMove: args => {
const target = args.control;
const source = args.e.calendar;
if (target !== source) {
source.events.remove(args.e);
}
},
onEventMoved: (args) => {
dp2.message("Moved: " + args.e.text());
},
onTimeRangeSelected: async (args) => {
const modal = await DayPilot.Modal.prompt("New event name:", "Event");
dp2.clearSelection();
if (modal.canceled) return;
dp2.events.add({
start: args.start,
end: args.end,
id: DayPilot.guid(),
resource: args.resource,
text: modal.result
});
dp2.message("Created");
},
});
dp2.init();
const app = {
loadData() {
const first = DayPilot.Date.today().firstDayOfWeek("en-us").addDays(1);
const events = [
{
start: first.addHours(12).addMinutes(15),
end: first.addHours(15),
id: 1,
text: "Event 1",
barColor: "#3c78d8",
barBackColor: "#a4c2f4"
},
{
start: first.addDays(1).addHours(10),
end: first.addDays(1).addHours(12),
id: 2,
text: "Event 2",
barColor: "#6aa84f",
barBackColor: "#b6d7a8"
},
{
start: first.addDays(1).addHours(13),
end: first.addDays(1).addHours(15),
id: 3,
text: "Event 3",
barColor: "#f1c232",
barBackColor: "#ffe599"
},
{
start: first.addDays(2).addHours(11).addMinutes(15),
end: first.addDays(2).addHours(16).addMinutes(15),
id: 4,
text: "Event 4",
barColor: "#cc0000",
barBackColor: "#ea9999"
},
];
dp1.update({events});
},
init() {
this.loadData();
}
};
app.init();