DayPilot.Calendar.onEventMove

The JavaScript Calendar component fires the onEventMove event handler when drag and drop event moving is completed (on drop), before the default action.

The default action is specified using the eventMoveHandling property (it's enabled by default).

This event handler lets you cancel the default action by calling the args.preventDefault() method if needed:

  • You can check custom rules for the target position.
  • You can ask users for a confirmation before actually moving the calendar event.

See also the onEventMoved event handler which is fired after the default action.

This event handler is also available in the open-source calendar component.

Declaration

DayPilot.Calendar.onEventMove(args);

Parameters

  • args.e - DayPilot.Event object representing the calendar event
  • args.newStart - the new event start (DayPilot.Date)
  • args.newEnd - the new event end (DayPilot.Date)
  • args.newResource - the ID of the new resource (in resource calendar mode)
  • args.external - a boolean value indicating the the event was dragged from an external source (Pro version only)
  • args.ctrl - status of the Ctrl key (boolean)
  • args.shift - status of the Shift key (boolean)
  • args.preventDefault() - cancels the default action set using eventMoveHandling

Example

dp.onEventMove = (args) => {
  if (args.external) {
    args.preventDefault();
    console.log("External drop forbidden");
  }
};

api=1

In api=1 mode this event is only called if eventMoveHandling is set to "JavaScript". This API mode is used in versions with an integrated server-side part (ASP.NET WebForms, ASP.NET MVC, Java).

Declaration

onEventMove(e, newStart, newEnd, newResource, external, ctrl, shift)

Parameters

  • e (DayPilot.Event) - the event reference
  • newStart (DayPilot.Date) - new event start
  • newEnd (DayPilot.Date) - new event end
  • newResource (string) - id of the new resource
  • external (boolean) - true if this was a move from an external source (outside of the Scheduler)
  • ctrl (boolean) - true if control key was pressed on drop
  • shift (boolean) - true if shift key was pressed on drop