search envelope-o feed check
Home Unanswered Active Tags New Question
user comment-o

Implementing Multi-Select of Events in scheduler

Asked by Michael Wolf
1 month ago.

I have purposed the daypilot scheduler to be able to create shifts for labour. However, I am unable to implement a mutli-copy solution into my instance.

I have initiated an empty array called multiclipboard, that uses the onEventClickhandling to add multiple events as I select them to the multiclipboard array no biggie.

 eventClickHandling: 'Enabled',
    onEventClick: async (args) => {
      if (args.ctrl) {
        console.log("multiclipboard", multiclipboard);

      else {
        // const selected = [];
        // console.log(selected)

Now, when I want to paste the new events on to a new resource or possibly replicate them on the same resource, Im getting a bit of mixed outputs. Am able to paste the first record okay, but the other records are picking the start date as the same for the first record, stacking them starting from the same date. Is it possible that I set new dates banking on number of days between dates (start and end) and some sort of tracking to know which event am dealing with? here’s my paste code so far under context menu selection handling.

          text: "Paste Multiple",
          onClick: (args) => {
            if (!multiclipboard) {
              alert("Nothing to paste, use Copy first");
            var totals = 0;
            var elapsed = false;
            const dp = args.source.calendar;
   => {
              console.log("item", item);
              var duration = new Date(item.end).getTime() - new Date(item.start).getTime();
              duration = duration / (3600 * 24000);
              function addDays(date, days) {
                var result = new Date(date);
                result.setDate(result.getDate() + days);
                return result;
              console.log("duration", duration);
              const newEvent = {
                start: elapsed? addDays(args.source.start, duration): args.source.start,
                end: elapsed? addDays(args.source.start, totals) : addDays(args.source.start, duration),
                id: DayPilot.guid(),
                barColor: item.barColor,
                resource: args.source.resource,
                shift: item.text,
                month: item.month,
                text: item.text,
                hours: item.hours,
                days: item.days,

              totals = totals + duration;
              elapsed = true;
              console.log("newEvent", newEvent);

Answer posted by Dan Letecky [DayPilot]
1 month ago.

There is a tutorial that shows how to do this:

Please let me know if it didn’t help!

Comment posted by Michael Wolf
1 month ago.

I am trying to follow the implementation but its not making sense to me as much. I just needed a way to map the starts and end correctly onto a new area, picking and calculating the new start and ends date, as is in the copied events

This question is more than 1 months old and has been closed. Please create a new question if you have anything to add.