You can add, remove, and update events on the client side.
Overview
- events.add(e, data)
- events.find(id)
- events.findRecurrent(masterId, time)
- events.remove(e, data)
- events.update(e, data)
See also
JavaScript
Adding Events
Events can be added to the Scheduler using events.add() method.
var e = new DayPilot.Event({ start:new DayPilot.Date(), end:(new DayPilot.Date()).addHours(5), id: DayPilot.guid(), text: "New Event", resource:'E' }); dps.events.add(e);
Updating Events
Events can be updated using events.update() method. The object representing the event can be acquired using events.find().
var e = dps.events.find('123'); dps.text('New Event Name'); // update the event text dps.events.update(e);
Removing Events
Events can be removed using events.remove() method. The object representing the event can be acquired using events.find().
var e = dps.events.find('123'); dps.events.remove(e);
ASP.NET WebForms
Event adding
Events can be added to the Scheduler using events.add() method.
var e = new DayPilot.Event({ start:new DayPilot.Date(), end:(new DayPilot.Date()).addHours(5), id: DayPilot.guid(), text: "New Event", resource:'E' }); dps.events.add(e).notify();
This example will add a new event called "New Event" and notify the server by firing EventAdd event.
protected void DayPilotScheduler1_EventAdd(object sender, EventAddEventArgs e) { // create the event in the database using custom method createEvent(e.Event.Value, e.Event.Start, e.Event.End, e.Event.Resource, e.Event.Text); // your method for updating the database // display a message to the user DayPilotScheduler1.UpdateWithMessage("Added."); }
Event updating
Events can be updated using events.update() method. The object representing the event must be acquired using events.find() or event.findRecurrent().
var e = dps.events.find('123'); dps.text('New Event Name'); // update the event text dps.events.update(e).notify();
This example will find an event with id "123", update the text and displayed HTML, and notify the server by firingEventUpdate event.
protected void DayPilotScheduler1_EventUpdate(object sender, EventUpdateEventArgs e) { createEvent(e.Event.Value, e.Event.Start, e.Event.End, e.Event.Resource, e.Event.Text); // your method for updating the database // display a message to the user DayPilotScheduler1.UpdateWithMessage("Updated."); }
Event removing
Events can be removed using events.remove() method. The object representing the event must be acquired usingevents.find() or event.findRecurrent().
var e = dps.events.find('123'); dps.events.remove(e).notify();
This example will find an event with id "123", remove it, and notify the server by firing EventRemove event.
protected void DayPilotScheduler1_EventRemove(object sender, EventRemoveEventArgs e)
{
removeEvent(e.Event.Value); // your method for updating the database
// display a message to the user DayPilotScheduler1.UpdateWithMessage("Deleted."); }