Skip to main content

DxSchedulerDataStorage.AppointmentLabelMappings Property

Specifies an object that defines how appointment label properties are mapped to data source fields.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v24.1.dll

NuGet Package: DevExpress.Blazor

Declaration

public DxSchedulerAppointmentLabelMappings AppointmentLabelMappings { get; set; }

Property Value

Type Description
DxSchedulerAppointmentLabelMappings

Information on how appointment label properties are mapped to data fields.

Remarks

Users can use color labels to categorize appointments. A label is displayed as the background of an appointment. The Scheduler has a built-in collection of eleven color labels.

Scheduler - Appointment labels

You can use the AppointmentLabelMappings property to create a collection of your own labels:

  1. Create a DxSchedulerDataStorage object that uses a constructor without parameters and specify appointment mappings. See the DxSchedulerAppointmentMappings class description for more information.
  2. Declare a class (for instance, LabelObject) that stores label settings and an ID.
  3. Create a collection of label source objects (LabelObject class instances) and define their settings.
  4. Assign the newly created collection to the storage’s AppointmentLabelsSource property.
  5. Assign the DxSchedulerAppointmentLabelMappings object to the AppointmentLabelMappings property. In this object, map the label’s source fields to the label’s properties.
  6. Optional. You can create custom fields for label items. Define custom fields in the label’s source object and add these fields to the CustomFieldMappings collection. For instance, the following code snippet adds the MyCustomField field to the LabelObject and maps this field to the label’s MyCustomProperty.
<DxScheduler DataStorage="@DataStorage">
    <Views>
        <DxSchedulerDayView DayCount="3"
                            TimeScale="@(new TimeSpan(1,0,0))"
                            WorkTime="new DxSchedulerTimeSpanRange(TimeSpan.FromHours(9), TimeSpan.FromHours(18))"
                            VisibleTime="new DxSchedulerTimeSpanRange(TimeSpan.FromHours(8), TimeSpan.FromHours(19))"
                            TimeIndicatorVisibility="SchedulerTimeIndicatorVisibility.Never">
        </DxSchedulerDayView>
        <DxSchedulerWeekView ShowWorkTimeOnly="true" />
        <DxSchedulerWorkWeekView ShowWorkTimeOnly="true" />
    </Views>
    <AppointmentCompactFormLayout Context="formInfo">
        <DxSchedulerSubjectFormLayoutItem></DxSchedulerSubjectFormLayoutItem>
        <DxSchedulerDescriptionFormLayoutItem></DxSchedulerDescriptionFormLayoutItem>
        <DxSchedulerLabelFormLayoutItem></DxSchedulerLabelFormLayoutItem>
    </AppointmentCompactFormLayout>
</DxScheduler>

@code {
    DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage() {
        // Specify appointment mappings here
        // ...
        AppointmentLabelsSource = LabelCollection.GetLabels(),
        AppointmentLabelMappings = new DxSchedulerAppointmentLabelMappings() {
            Id = "Id",
            Caption = "LabelCaption",
            Color = "LabelColor",
            // Uncomment the line below and comment the line above to specify other background options.
            //BackgroundCssClass = "BackgroundCssClass",
            TextCssClass = "TextCssClass",
            // Map the source object's custom field to the label's custom property.
            CustomFieldMappings = new List<DxSchedulerCustomFieldMapping> {
                new DxSchedulerCustomFieldMapping { Name = "MyCustomProperty", Mapping = "MyCustomField" }
            }
        }
    };
}

Scheduler Custom Labels

Note

When you use templates to customize appointment appearance, the Color, BackgroundCssClass, and TextCssClass property values are not applied to appointments. In the template, you can use the context.Label parameter to access these property values.

See Also