JavaScript
It is possible to modify events using the client-side events API.
The events will be updated immediately.
var e = dps.events.find('123');
e.text('New Event Name'); // update the event text
dps.events.update(e);
var e = dps.events.find('124');
e.text('New Event Name'); // update the event text
dps.events.update(e);
ASP.NET WebForms
Event Moving and Resizing
If you use EventResizeHandling=Notify and EventMoveHandling=Notify the Scheduler will update the events immediately on the client side and the server will be notified after the change. Standard OnEventResize and OnEventMove event will be fired.
<DayPilot:DayPilotScheduler ID="DayPilotScheduler1" runat="server" ... EventMoveHandling="Notify" OnEventMove="DayPilotScheduler1_EventMove" EventResizeHandling="Notify" OnEventResize="DayPilotScheduler1_EventResize" />
Process the event in the code behind.
protected void DayPilotScheduler1_EventMove(object sender, DayPilot.Web.Ui.Events.EventMoveEventArgs e)
{
// update the database here
UpdateWithMessage("Event was moved.");
}
Custom Event Changes
<DayPilot:DayPilotScheduler ID="DayPilotScheduler1" runat="server" ... OnNotify="DayPilotScheduler1_Notify" OnEventUpdate="DayPilotScheduler1_EventUpdate" OnEventAdd="DayPilotScheduler1_EventAdd" OnEventRemove="DayPilotScheduler1_EventRemove" />
You can also submit custom changes done using JavaScript:
var e = dps.events.find('123');
e.text('New Event Name'); // update the event text
dps.events.update(e).notify();
As soon as you call .notify() it will fire EventUpdate event on the server side:
protected void DayPilotScheduler1_EventUpdate(object sender, EventUpdateEventArgs e)
{
// do the database changes here
}
You can submit multiple changes at once:
var e = dps.events.find('123');
e.text('New Event Name'); // update the event text
dps.events.update(e).queue();
var e = dps.events.find('124');
e.text('New Event Name'); // update the event text
dps.events.update(e).queue();
dps.queue.notify();
All the submitted events are available in e.Queue in OnNotify.
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);
}
ASP.NET MVC
Event Moving and Resizing
If you use EventResizeHandling=Notify and EventMoveHandling=Notify the Scheduler will update the events immediately on the client side and the server will be notified after the change. Standard OnEventResize and OnEventMove event will be fired.
@Html.DayPilotScheduler("dps", new DayPilotSchedulerConfig {
BackendUrl = ResolveUrl("~/Scheduler/Backend"),
...
EventMoveHandling = EventMoveHandlingType.Notify,
EventResizeHandling = EventResizeHandlingType.Notify
})
Don't call Update() in these event handlers if you don't want to refresh all events.
protected override void OnEventMove(EventMoveArgs e)
{
new EventManager(Controller).EventMove(e.Id, e.NewStart, e.NewEnd, e.NewResource);
// no Update() or UpdateWithMessage() call
}
Custom Event Changes
You can also submit custom changes done using JavaScript:
var e = dps.events.find('123');
e.text('New Event Name'); // update the event text
dps.events.update(e).notify();
See also:
As soon as you call .notify() it will fire OnNotify on the server side:
protected override void OnNotify(NotifyArgs e)
{
foreach(DayPilotArgs a in e.Queue)
{
if (a is EventUpdateArgs)
{
EventUpdateArgs updateArgs = (EventUpdateArgs) a;
string id = updateArgs.Event.Value;
string newText = updateArgs.New.Text;
// update the db
}
}
}
You can submit multiple changes at once:
var e = dps.events.find('123');
e.text('New Event Name'); // update the event text
dps.events.update(e).queue();
var e = dps.events.find('124');
e.text('New Event Name'); // update the event text
dps.events.update(e).queue();
dps.queue.notify();
All the submitted events are available in e.Queue in OnNotify.
DayPilot