User Interaction
An end user can update an appointment in one of the following ways.
- Reschedule an appointment by moving it to another cell.
- Extend or shorten an appointment by dragging its top or bottom border.
- Change the appointment details by focusing the appointment and clicking "Open Appointment" afterwards.
When a user finishes updates, they are saved to the dataSource.
If a user updates a recurring appointment, the Scheduler displays a dialog where users can choose between editing the current appointment and editing the entire series of recurring appointments. If you do not want this dialog to appear, choose the edit mode beforehand using the recurrenceEditMode property.
- $(function() {
- $("#schedulerContainer").dxScheduler({
- // ...
- recurrenceEditMode: 'occurrence' // or 'series' | 'dialog'
- });
- });
To prevent a user from updating an appointment, set the editing.allowUpdating property to false.
- $(function() {
- $("#schedulerContainer").dxScheduler({
- // ...
- editing: { allowUpdating: false }
- });
- });
API
To update an appointment, call the updateAppointment(target, appointment) method. This method updates the target appointment from the data source with the fields of the appointment parameter.
- $(function() {
- var appointments = [{
- text: "Website Re-Design Plan",
- startDate: new Date("2016-04-25T09:00:00.000Z"),
- endDate: new Date("2016-04-25T09:30:00.000Z")
- },
- // ...
- ];
- var scheduler = $("#schedulerContainer").dxScheduler({
- dataSource: appointments,
- currentDate: new Date(2016, 4, 25)
- }).dxScheduler("instance");
- $("#modifyButton").dxButton({
- text: "Modify",
- onClick: function () {
- scheduler.updateAppointment(appointments[0], { text: "Planning" } );
- }
- });
- });
Events
To execute certain commands before or after an appointment was updated, handle the appointmentUpdating or appointmentUpdated event. If the event handling function is not going to be changed during the lifetime of the UI component, assign it to the corresponding onEventName property when you configure the UI component.
- $(function () {
- $("#schedulerContainer").dxScheduler({
- // ...
- onAppointmentUpdating: function (e) {
- // Handler of the "appointmentUpdating" event
- },
- onAppointmentUpdated: function (e) {
- // Handler of the "appointmentUpdated" event
- }
- });
- });
If you are going to change event handlers at runtime, or if you need to attach several handlers to a single event, subscribe to the events using the on(eventName, eventHandler) method.
- var updatedEventHandler1 = function (e) {
- // First handler of the "updated" event
- };
- var updatedEventHandler2 = function (e) {
- // Second handler of the "updated" event
- };
- $("#schedulerContainer").dxScheduler("instance")
- .on("appointmentUpdated", updatedEventHandler1)
- .on("appointmentUpdated", updatedEventHandler2);