ReadOnlyBehavior
RadScheduler's ReadOnlyBehavior is responsible for determining which operations are applicable to the appointments in the control. It can be customized in order to implement logic for whether you can save, edit, drag, resize, delete an appointment and edit a slot. This is done by inheriting the ReadOnlyBehavior class and overriding one or several of its virtual methods:
- CanSaveAppointment: Override to add logic for whether an appointment can be saved.
- CanEditAppointment: Override to add logic for whether an appointment can be edited.
- CanDragAppointment: Override to add logic for whether an appointment can be dragged.
- CanResizeAppointment: Override to add logic for whether an appointment can be resized.
- CanDeleteAppointment: Override to add logic for whether an appointment can be deleted.
- CanEditSlot: Override to add logic for whether a slot can be edited.
Implementing Custom ReadOnlyBehavior
To implement a custom readonlybehavior, you have to create a class which inherits ReadOnlyBehavior.
Example 1: Custom ReadOnlyBehavior
public class CustomReadonlyBehavior : ReadOnlyBehavior
{
public override bool CanSaveAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return base.CanSaveAppointment(readOnlySettings, occurrence);
}
public override bool CanEditAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return base.CanEditAppointment(readOnlySettings, occurrence);
}
public override bool CanDragAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return base.CanDragAppointment(readOnlySettings, occurrence);
}
public override bool CanResizeAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return base.CanResizeAppointment(readOnlySettings, occurrence);
}
public override bool CanDeleteAppointment(IReadOnlySettings readOnlySettings, IOccurrence occurrence)
{
return base.CanDeleteAppointment(readOnlySettings, occurrence);
}
public override bool CanEditSlot(IReadOnlySettings readOnlySettings, Slot slot)
{
return base.CanEditSlot(readOnlySettings, slot);
}
}
Note, that by default the base class implementation of the ReadOnlyBehavior class works with the ReadOnlySlots of the RadScheduler. If you want to change the default behavior, you can introduce custom logic.
Then you need to set it to RadScheduler's ReadOnlyBehavior property.
Example 2: Setting ReadOnlyBehavior
<telerik:RadScheduler>
<telerik:RadScheduler.ReadOnlyBehavior>
<local:CustomReadonlyBehavior />
</telerik:RadScheduler.ReadOnlyBehavior>
</telerik:RadScheduler>
In this example the namespace "local" is referring to the namespace in which the CustomReadonlyBehavior is declared.