DayPilot.Scheduler.onEventMoving

Real-time event that is fired whenever the event shadow is moved to another position during drag & drop event moving.

Declaration

onEventMoving(args)

Parameters

  • args.allowed - boolean value that determines whether it is possible to drop the event at this location
  • args.start - start date/time of the current position (DayPilot.Date object)
  • args.end  - end date/time of the current position (DayPilot.Date object)
  • args.duration - duration of the event (DayPilot.Duration object)
  • args.e - event object (DayPilot.Event object)
  • args.external - true if the event comes from an external source
  • args.html - HTML of the shadow object (since 8.3.2589)
  • args.resource - id of the current row (string)
  • args.row - an object representing the current row (DayPilot.Row)
  • args.position - position index inside a cell when event position mode is enabled
  • args.left.html - HTML of the inline start indicator; default value is set to args.start.toString(calendar.eventMovingStartEndFormat)
  • args.left.enabled - when set to true, the inline start indicator is displayed; default value is set to calendar.eventMovingStartEndEnabled
  • args.right.html - HTML of the inline end indicator; default value is set to args.start.toString(calendar.eventMovingStartEndFormat)
  • args.right.enabled - when set to true, the inline end indicator is displayed; default value is set to calendar.eventMovingStartEndEnabled

Examples

External message

dp.onEventMoving = function(args) {
  $("#msg").html(args.start + " " + args.end + " " + args.resource);
};

Inline message

dp.onEventMoving = function(args) {
  // don't allow moving from A to B
  if (args.e.resource() === "A" && args.resource === "B") {
      args.left.enabled = false;
      args.right.enabled = true;
      args.right.html = "You can't move an event from resource A to B";

      args.allowed = false;
  }
};

Prevent moving events outside of the visible range

dp.onEventMoving = function(args) {

  if (args.end > dp.visibleEnd()) {
      args.left.enabled = true;
      args.left.html = "You can't drag the event out of the visible range";
      args.right.enabled = true;
      args.allowed = false;
  }

  if (args.start < dp.visibleStart()) {
      args.right.enabled = true;
      args.right.html = "You can't drag the event out of the visible range";
      args.left.enabled = true;
      args.allowed = false;
  }
};