EventMove event stores the Ctrl and Shift key status. This allows implementation of drag and drop event copying.

JavaScript

Drag and drop event moving is enabled by default (.eventMoveHandling = "Update")

See also

Example

<div id="dp"></div>
<script type="text/javascript">
  var dp = new DayPilot.Calendar("dp");
  dp.onEventMoved = function (args) {
    dp.message("Moved: " + args.e.text());

    // your own AJAX call to the server to notify it about the change
  };
  // ...
  dp.init();
</script>

ASP.NET WebForms

Drag and drop event moving is disabled by default.

It can be enabled using EventMoveHandling property. It has to be set to one of the following values:

  • CallBack
  • PostBack
  • Notify
  • JavaScript

PostBack event handling type will fire a server-side event handler (EventMove) using a PostBack (or partial AJAX PostBack if the Calendar is inside an UpdatePanel).

CallBack event handling type will fire a server-side event handler (EventMove) using an AJAX callback. CallBack is much faster than PostBack (and partial PostBack).

Notify event handling type will update the Calendar on the client immediately and then notifies the server (EventMove) using an AJAX callback. Notify is much faster than CallBack.

JavaScript event handling will fire the JavaScript code specified in EventMoveJavaScript.

Server-Side Handler

<DayPilot:DayPilotMonth runat="server" id="DayPilotMonth1"
  ...
  EventMoveHandling = "CallBack"
  OnEventMove="DayPilotMonth1_EventMove" 
/>

Example EventMove handler:

protected void DayPilotMonth1_EventMove(object sender, EventMoveEventArgs e)
{
  // update the database
  // ...

  // reload events and refresh the calendar on the client side
  DayPilotMonth1.DataSource = LoadData();  // your method
  DayPilotMonth1.DataBind();
DayPilotMonth1.UpdateWithMessage("Event moved.");
}

If any changes are made to the event data set (which is the typical case), it is necessary to redraw the event set on the client side using an Update() call.

See Also

ASP.NET MVC

Drag & drop event moving is disabled by default.

It can be enabled using EventMoveHandling property. It has to be set to one of the following values:

  • CallBack
  • Notify
  • JavaScript

CallBack event handling will fire a server-side event handler (OnEventMove) using an AJAX callback.

Notify event handling type will update the Calendar on the client immediately and then notifies the server using an AJAX call. Notify is much faster than CallBack.

JavaScript event handling will fire the JavaScript code specified in EventMoveJavaScript.

Server-Side Handler

@Html.DayPilotMonth("dpm", new DayPilotMonthConfig {
  BackendUrl = ResolveUrl("~/Month/Backend"),
  ...
  EventMoveHandling = EventMoveHandlingType.CallBack
})

The EventMove event can be handled by overriding the OnEventMove method in the DayPilotCalendar implementing class:

protected override void OnEventMove(EventMoveArgs e)
{
  new EventManager(Controller).EventMove(e.Id, e.NewStart, e.NewEnd);
  Update();
}

protected override void OnFinish()
{
  // only load the data if an update was requested by an Update() call
  if (UpdateType == CallBackUpdateType.None)
  {
    return;
  }

  Events = new EventManager(Controller).FilteredData(VisibleStart, VisibleEnd).AsEnumerable();  // custom method for loading data

  DataStartField = "start";
  DataEndField = "end";
  DataTextField = "text";
  DataIdField = "id";

}

If any changes are made to the event data set (which is the typical case), it is necessary to redraw the event set on the client side using an Update() call.