DxScheduler.AppointmentRemoving Event
Fires before an appointment is removed from the AppointmentsSource object.
Namespace: DevExpress.Blazor
Assembly: DevExpress.Blazor.v21.2.dll
NuGet Package: DevExpress.Blazor
Declaration
[Parameter]
public EventCallback<SchedulerAppointmentOperationEventArgs> AppointmentRemoving { get; set; }
Event Data
The AppointmentRemoving event's data class is SchedulerAppointmentOperationEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
Appointment | Specifies an appointment that is modified (added, updated or removed). |
Cancel | Specifies whether the corresponding appointment operation (addition, update or removal) should be canceled. |
Remarks
To cancel an appointment removal, use the event argument’s Cancel property. To get information about the removed appointment, use the event argument’s Appointment property.
If the operation is not canceled, the appointment is removed from the AppointmentsSource object and the AppointmentRemoved event is raised.
The code below uses the Cancel property to restrict non-Admin users to remove appointments from the DxScheduler.
<DxScheduler StartDate="@(new DateTime(2018, 10, 10))"
DataStorage="@DataStorage"
AppointmentRemoving="(e) => AppointmentRemoving(e)">
</DxScheduler>
@if (PopupVisible) {
<DxPopup HeaderText="Warning" CloseButtonClick="@(() => PopupVisible = false)">
<p>You are not allowed to remove appointments from the scheduler. Please contact your system administrator for details.</p>
</DxPopup>
}
@code {
bool popupVisible = false;
bool PopupVisible { get => popupVisible; set { popupVisible = value; InvokeAsync(StateHasChanged); } }
void AppointmentRemoving(SchedulerAppointmentOperationEventArgs e) {
if (currentUser.Role != "Admin") {
e.Cancel = true;
PopupVisible = true;
}
}
}