Skip to main content

DxSchedulerSourceObjectContainer.SourceObject Property

A data source object to which a Scheduler item is bound.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v25.2.dll

NuGet Package: DevExpress.Blazor

Declaration

public object SourceObject { get; }

Property Value

Type Description
Object

The data source object.

Remarks

You can use the SourceObject property to access the target appointment’s source object when you manage appointments in code.

The following code snippet does the following:

@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

Refer to Bind Scheduler to Remote Data for additional information.

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SourceObject property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also