DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot AJAX Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot AJAX Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot AJAX Scheduler
DayPilot » Knowledge Base » How to copy events using drag&drop (Ctrl key)

How to copy events using drag&drop (Ctrl key)

Last revision: Dec 10, 2010

DayPilot Pro 5.9 will be able to detect Ctrl and Shift key status during drag&drop move operation.

Ctrl and Shift key status is saved in "ctrl" and "shift" variables available to the JavaScript EventMove handler (EventMoveJavaScript). 

Example 1

Client side

EventMoveJavaScript="dpc.eventMoveCallBack(e, newStart, newEnd, newResource, {ctrl: ctrl, shift: shift} )"

Server side (C#)

    protected void DayPilotScheduler1_EventMove(object sender, DayPilot.Web.Ui.Events.EventMoveEventArgs e)
    {
        bool shift = (bool) e.Data["shift"];
        bool ctrl = (bool) e.Data["ctrl"];

        if (ctrl) {
          // copy the event in the DB (INSERT)
        }
        else if (shift) {
          // move the event in the DB (UPDATE)
        }

        setDataSourceAndBind(); // custom method that loads the data from a DB, assigns DataSource and calls DataBind()
        DayPilotScheduler1.Update("Event moved");
    }

Server side (VB.NET)

    Protected Sub DayPilotScheduler1_EventMove(ByVal sender As Object, ByVal e As DayPilot.Web.Ui.Events.EventMoveEventArgs) Handles DayPilotScheduler1.EventMove

        Dim shift As Boolean = CType(e.Data("shift"), Boolean)
        Dim ctrl As Boolean = CType(e.Data("ctrl"), Boolean)


        If ctrl Then
            ' copy the event in the DB (INSERT)
        ElseIf shift Then
            ' move the event in the DB (UPDATE)
        End If

        setDataSourceAndBind() ' custom method that loads the data from a DB, assigns DataSource and calls DataBind() As setDataSourceAndBind()
        DayPilotScheduler1.Update("Event moved")
    End Sub

Example 2

EventMoveJavaScript="if (ctrl) yourCopyOperation(e, newStart, newEnd, newResource); else if (shift) yourMoveOperation(e, newStart, newEnd, newResource) else yourDefaultOperation(e, newStart, newEnd, newResource);"

It's necessary to handle the status properly on the server side.

Availability

Available: DayPilot Pro for ASP.NET build 5.8.1968

Controls: Calendar, Scheduler, Month

Related

JavaScript error: "dps" is undefined
Event Calendar for jQuery (ASP.NET MVC)
How to add an event to the scheduler on the client side (JavaScript)
How To Set Up Overnight Shift Scheduling with DayPilot Calendar