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 add an event to the scheduler on the client side (JavaScript)

How to add an event to the scheduler on the client side (JavaScript)

Last revision: May 24, 2012


It is possible to add an event to the Scheduler on the client side without contacting the server.


var e = new DayPilot.Event({
start:new DayPilot.Date(),
end:(new DayPilot.Date()).addHours(5),
value: DayPilot.guid(),
text: "New Event", resource:'E'});;

Server notification

It is possible to notify the server about this change. The events.add() method returns a DayPilot.Action object that can be used to send the notification.

Immediate notification;

This call will fire EventUpdate event on the server side.

Queued notification

// add the action to the queue;

This call will add the action details to the queue.

// send the queue to the server

This queue.notify() call will send all queued actions to the server. It will fire Notify event. 

    protected void DayPilotScheduler1_Notify(object sender, DayPilot.Web.Ui.Events.Scheduler.NotifyEventArgs e)
        foreach(DayPilotEventArgs ea in e.Queue)
            if (ea is EventAddEventArgs)
                EventAddEventArgs em = (EventAddEventArgs)ea;
                DayPilotScheduler1_EventAdd(sender, em);

            else if (ea is EventMoveEventArgs)
                EventMoveEventArgs em = (EventMoveEventArgs) ea;
                DayPilotScheduler1_EventMove(sender, em);

            else if (ea is EventRemoveEventArgs)
                EventRemoveEventArgs em = (EventRemoveEventArgs) ea;
                DayPilotScheduler1_EventRemove(sender, em);
            else if (ea is EventUpdateEventArgs)
                DayPilotScheduler1_EventUpdate(sender, (EventUpdateEventArgs) ea);

        string msg = String.Format("Queue saved ({0} actions).", e.Queue.Count);

See also


How to prevent event overlapping
How to show event-specific context menu
How to implement Copy & Paste in the Calendar
How to open an event edit dialog from a context menu (Calendar)