DxSchedulerResourceMappings Class

Maps the resource's properties to the data source fields.

Namespace: DevExpress.Blazor

Assembly: DevExpress.Blazor.v20.2.dll

Declaration

public class DxSchedulerResourceMappings :
    DxSchedulerMappingsBase

The following members accept/return DxSchedulerResourceMappings objects:

Remarks

The DxSchedulerResourceMappings class object is used to map the ResourcesSource's data fields to the resource properties in the Scheduler component.

@code {
    public class ResourceObject {
        public int Id { get; set; }
        public string Caption { get; set; }
        public System.Drawing.Color Color { get; set; }
        public string TextCssClass { get; set; }
        public string BackgroundCssClass { get; set; }
    }

    DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage() {
        ResourcesSource = new List<ResourceObject>() {
            new ResourceObject() { 
                Id = "1", 
                Caption = "Resource One", 
                Color = System.Drawing.Color.Red, 
                TextCssClass = "apt-text-red", 
                BackgroundCssClass = "apt-bg-lightpink",
            },
            new ResourceObject() { 
                Id = "2", 
                Caption = "Resource Two", 
                Color = System.Drawing.Color.Green
                TextCssClass = "apt-text-green", 
                BackgroundCssClass = "apt-text-lightgreen"
            },
        },
        ResourceMappings = new DxSchedulerResourceMappings() {
            Id = "Id",
            Caption = "Caption",
            Color = "Color",
            TextCssClass = "TextCssClass", 
            BackgroundCssClass = "BackgroundCssClass"
        }
    };
}

Run Demo: Scheduler - Resources

Resource's Custom Fields

You can add custom properties to a resource:

  1. Define custom fields in the resource's source object.
  2. Add created fields to the CustomFieldMappings collection.

The code below adds the MyCustomField field to ResourceObject and maps this field to the resource's MyCustomProperty property:

@code {
    public class ResourceObject {
        public int Id { get; set; }
        public string LabelName { get; set; }
        public System.Drawing.Color LabelColor { get; set; }
        public string MyCustomField { get; set; } // a custom field
    }

    DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage() {
        ResourcesSource = new List<ResourceObject>() {
            new ResourceObject() { 
                Id = 1, 
                ResourceName = "Resource One", 
                ResourceColor = System.Drawing.Color.Aqua, 
                MyCustomField = "custom text for Resource One" 
            },
            new ResourceObject() { 
                Id = 2, 
                ResourceName = "Resource Two", 
                ResourceColor = System.Drawing.Color.Beige, 
                MyCustomField = "custom text for Resource Two"
            },
        },
        ResourceMappings = new DxSchedulerResourceMappings() {
            Id = "Id",
            Caption = "ResourceName",
            Color = "ResourceColor",
            // Map the source object's custom field to the resource's custom property
            CustomFieldMappings = new List<DxSchedulerCustomFieldMapping> {
                new DxSchedulerCustomFieldMapping { Name = "MyCustomProperty", Mapping = "MyCustomField" }
            }
        }
    };
}

Inheritance

Object
DevExpress.Blazor.Scheduler.Internal.BindableBase
DxSchedulerMappingsBase
DxSchedulerResourceMappings
See Also