How to: Prevent End-Users from Editing Appointments
- 2 minutes to read
In some real-life applications it might be necessary to prevent end-users from editing (copying, deleting, dragging, etc.) the appointments shown within the SchedulerControl. For instance, it’s necessary to show all the appointments to end-users as read-only.
To do this you should access the customization settings via the SchedulerControl.OptionsCustomization property to implement end-user restrictions in your scheduling application. The following restrictions are possible in the XtraScheduler:
Restriction | Description |
---|---|
SchedulerOptionsCustomization.AllowAppointmentConflicts | Specifies whether an end-user is allowed to share the schedule time between two or more appointments. |
SchedulerOptionsCustomization.AllowAppointmentCopy | Specifies whether an end-user is allowed to copy appointments. |
SchedulerOptionsCustomization.AllowAppointmentCreate | Specifies whether an end-user is allowed to create new appointments. |
SchedulerOptionsCustomization.AllowAppointmentDelete | Specifies whether an end-user is allowed to delete appointments. |
SchedulerOptionsCustomization.AllowAppointmentDrag | Specifies whether an end-user is allowed to drag and drop appointments to another time slot or date. |
SchedulerOptionsCustomization.AllowAppointmentDragBetweenResources | Specifies whether an end-user is allowed to drag and drop appointments between resources. |
SchedulerOptionsCustomization.AllowAppointmentEdit | Specifies whether an end-user is allowed to edit appointments. |
SchedulerOptionsCustomization.AllowAppointmentMultiSelect | Specifies whether an end-user is allowed to select more than one appointment simultaneously. |
SchedulerOptionsCustomization.AllowAppointmentResize | Specifies whether an end-user is allowed to change the time boundaries of appointments. |
SchedulerOptionsCustomization.AllowInplaceEditor | Specifies whether an in-place editor can be activated for an appointment. |
You can set a corresponding value as required, e.g. set it ot UsedAppointmentType.None to prohibit a particular action for all appointment types, or set it to UsedAppointmentType.Recurring to allow it for recurring appointments only.
If you set one of OptionsCustomization.Allow* properties to UsedAppointmentType.Custom, a related Allow* event will fire, in which you can decide how to handle a particular case. For example, to prevent user Sam from dragging appointments, you can use the following code:
schedulerControl1.OptionsCustomization.AllowAppointmentDrag = UsedAppointmentType.Custom;
schedulerControl1.AllowAppointmentDrag += new AppointmentOperationEventHandler
(schedulerControl1_AllowAppointmentDrag);
// ...
void schedulerControl1_AllowAppointmentDrag(object sender, AppointmentOperationEventArgs e) {
if (user_id == "Sam") e.Allow = false;
}