Back to Devexpress

DxScheduler.AppointmentCreating Event

blazor-devexpress-dot-blazor-dot-dxscheduler-965a4247.md

latest2.7 KB
Original Source

DxScheduler.AppointmentCreating Event

Fires before an appointment is created.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

csharp
[Parameter]
public EventCallback<SchedulerAppointmentOperationEventArgs> AppointmentCreating { get; set; }

Event Data

The AppointmentCreating event's data class is SchedulerAppointmentOperationEventArgs. The following properties provide information specific to this event:

PropertyDescription
AppointmentSpecifies the target appointment.
CancelGets or sets a value indicating whether the event should be canceled. Inherited from CancelEventArgs.

Remarks

To cancel the operation, use the event argument’s Cancel property. If you need to access the appointment and modify its properties, use the event argument’s Appointment property.

The following code snippet uses the Cancel property to restrict non-Admin users to create appointments in the DxScheduler.

razor
<DxScheduler StartDate="@(new DateTime(2018, 10, 10))"
             DataStorage="@DataStorage" 
             AppointmentCreating="(e) => AppointmentCreating(e)">
</DxScheduler>

@if (PopupVisible) {
    <DxPopup HeaderText="Warning" CloseButtonClick="@(() => PopupVisible = false)">
        <p>You are not allowed to create new appointments in 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 AppointmentCreating(SchedulerAppointmentOperationEventArgs e) {
      if (currentUser.Role != "Admin") {
          e.Cancel = true;
          PopupVisible = true;
      }
  }
}

See Also

DxScheduler Class

DxScheduler Members

DevExpress.Blazor Namespace