Skip to main content

DevExpress v24.2 Update — Your Feedback Matters

Our What's New in v24.2 webpage includes product-specific surveys. Your response to our survey questions will help us measure product satisfaction for features released in this major update and help us refine our plans for our next major release.

Take the survey Not interested

DxScheduler.AppointmentRemoved Event

Fires after an appointment is removed from the AppointmentsSource object.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.2.dll

NuGet Package: DevExpress.Blazor

#Declaration

C#
[Parameter]
public EventCallback<DxSchedulerAppointmentItem> AppointmentRemoved { get; set; }

#Parameters

Type Description
DxSchedulerAppointmentItem

A DxSchedulerAppointmentItem object that stores a removed appointment.

#Remarks

Use the AppointmentRemoved event to get information about a removed appointment after it has been deleted from the AppointmentsSource object.

Note

To cancel an appointment removal in code, use the AppointmentRemoving event.

The following code snippet does the following:

Razor
@inject IDbContextFactory<MedicsSchedulingContext> MedicsSchedulingContextFactory
@implements IDisposable

<DxScheduler StartDate="@startDate"
             DataStorage="@DataStorage"
             AppointmentUpdated="@AppointmentUpdated"
             AppointmentInserted="@AppointmentInserted"
             AppointmentRemoved="@AppointmentRemoved"
             GroupType="SchedulerGroupType.Resource">
    <DxSchedulerDayView DayCount="1" ShowWorkTimeOnly="true"></DxSchedulerDayView>
    ...
        <Scales>
            <DxSchedulerTimeScale Unit="@SchedulerTimeScaleUnit.Day" UnitCount="1"></DxSchedulerTimeScale>
            <DxSchedulerTimeScale Unit="@SchedulerTimeScaleUnit.Hour" UnitCount="2"></DxSchedulerTimeScale>
        </Scales>
    </DxSchedulerTimelineView>
</DxScheduler>

@code {
    DateTime startDate { get; set; } = new DateTime(2016, 10, 10);
    MedicsSchedulingContext dbContext { get; set; }

    DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage() {
            AppointmentsSource = null,
            AppointmentMappings = new DxSchedulerAppointmentMappings() {
                Id = "Id",
                Type = "EventType",
                Start = "StartTime",
                End = "EndTime",
                Subject = "Subject",
                AllDay = "AllDay",
                Location = "Location",
                Description = "Description",
                LabelId = "Label",
                StatusId = "Status",
                ResourceId = "MedicId",
                RecurrenceInfo = "RecurrenceInfo"
            },
            ResourcesSource = null,
            ResourceMappings = new DxSchedulerResourceMappings() {
                Id = "Id",
                Caption = "DisplayName"
            }
        };

    protected override void OnInitialized() {
        dbContext = MedicsSchedulingContextFactory.CreateDbContext();
        DataStorage.AppointmentsSource = dbContext.MedicalAppointments.ToList();
        DataStorage.ResourcesSource = dbContext.Medics.ToList();
    }

    void AppointmentInserted(DxSchedulerAppointmentItem e) {
        dbContext.Add(e.SourceObject);
        dbContext.SaveChanges();
    }

    void AppointmentUpdated(DxSchedulerAppointmentItem e) {
        dbContext.SaveChanges();
    }

    void AppointmentRemoved(DxSchedulerAppointmentItem e) {
        dbContext.Remove(e.SourceObject);
        dbContext.SaveChanges();
    }

    public void Dispose() {
        dbContext?.Dispose();
    }
}

Bind to data with EF Core

See Also