Back to Devexpress

DxScheduler.AppointmentStartDragging Event

blazor-devexpress-dot-blazor-dot-dxscheduler-8822e148.md

latest3.4 KB
Original Source

DxScheduler.AppointmentStartDragging Event

Fires when a user starts dragging an appointment.

Namespace : DevExpress.Blazor

Assembly : DevExpress.Blazor.v25.2.dll

NuGet Package : DevExpress.Blazor

Declaration

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

Event Data

The AppointmentStartDragging 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 target appointment, use the event argument’s Appointment property.

Note

If AppointmentDragMode is set to Client, the component does not raise the AppointmentStartDragging event.

The following code snippet prevents users from moving appointments scheduled outside of work hours:

razor
<DxScheduler StartDate="@DateTime.Today"
             DataStorage="@DataStorage"              
             GroupType="SchedulerGroupType.Resource"
             AppointmentStartDragging="OnStartDragging">
    ...
</DxScheduler>

<DxPopup @bind-Visible="@AlertVisible"
         CloseOnEscape="true"
         CloseOnOutsideClick="true"
         ShowCloseButton="true"
         HeaderText="Warning!"
         BodyText="The appointment can belong only to the current user and can start and end only during the working time interval.">
</DxPopup>

@code {
    ...

    DxSchedulerTimeSpanRange WorkTime = new DxSchedulerTimeSpanRange(TimeSpan.FromHours(9), TimeSpan.FromHours(18));
    bool AlertVisible = false;
    int CurrentUserResourceId = 0;
    bool IsCurrentUsersAppointment(DxSchedulerAppointmentItem apt) => apt.ResourceId as int? == CurrentUserResourceId;

    bool IsInWorkTime(DxSchedulerAppointmentItem apt) =>
        apt.AllDay ||
        apt.Start - apt.Start.Date >= WorkTime.Start
        && WorkTime.End >= apt.End - apt.End.Date;

    void OnStartDragging(SchedulerAppointmentOperationEventArgs args) {
        if (!IsCurrentUsersAppointment(args.Appointment) || !IsInWorkTime(args.Appointment)) {
            args.Cancel = true;
            AlertVisible = true;
    }
}

Run Demo: Scheduler - User Action Customization

See Also

DxScheduler Class

DxScheduler Members

DevExpress.Blazor Namespace