DayPilot Knowledge Base

AJAX Calendar/Scheduling Controls
DayPilot Pro (AJAX Calendar Control)
» DayPilot ASP.NET Calendar
DayPilot Pro (AJAX Monthly Calendar Control)
» DayPilot ASP.NET Monthly Calendar
DayPilot Pro (AJAX Scheduler Control)
» DayPilot ASP.NET 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

scheduler add event

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

Example

var e = new DayPilot.Event({
start:new DayPilot.Date(),
end:(new DayPilot.Date()).addHours(5),
value: DayPilot.guid(),
text: "New Event", resource:'E'}); dps.events.add(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

dps.events.add(e).notify();

This call will fire EventUpdate event on the server side.

Queued notification

// add the action to the queue
dps.events.add(e).queue();

This call will add the action details to the queue.

// send the queue to the server
dps.queue.notify();

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);
        DayPilotScheduler1.UpdateWithMessage(msg);
    }

See also

Related

How to show the selected date using a Label control
How to show event-specific context menu
How to show event details in a modal dialog (modal.js)
How to open a new event dialog using TimeRangeSelected event (modal.js)