menu

Blazor

  • Code Examples
  • Upgrade Guide
  • User Guide
  • Demos
  • Support
  • Forums
  • Download
Class ScheduleResource<TValue, TItem> - API Reference

    Show / Hide Table of Contents

    Class ScheduleResource<TValue, TItem>

    A class that represents the resource related configurations and the options for binding its data.

    Inheritance
    System.Object
    SfBaseComponent
    SfDataBoundComponent
    ScheduleResource<TValue, TItem>
    Implements
    IScheduleResources
    Inherited Members
    SfDataBoundComponent.SetDataManager<T>(Object)
    SfDataBoundComponent.OnAfterRenderAsync(Boolean)
    SfDataBoundComponent.DataManager
    SfDataBoundComponent.MainParent
    SfBaseComponent.Dispose()
    SfBaseComponent.Dispose(Boolean)
    SfBaseComponent.OnObservableChange(String, Object, Boolean, NotifyCollectionChangedEventArgs)
    Namespace: Syncfusion.Blazor.Schedule
    Assembly: Syncfusion.Blazor.dll
    Syntax
    public class ScheduleResource<TValue, TItem> : SfDataBoundComponent, IScheduleResources
    Type Parameters
    Name Description
    TValue

    The type of the resource ID field value from the data source model.

    TItem

    The type of the data source model.

    Remarks

    You can configure the collection of schedule resource by specifying values for the corresponding properties with in the ScheduleResources tag directive.

    Examples

    The following code example shows how to configure the resource in scheduler:

    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" DataSource="@OwnersData" Field="OwnerId" Title="Owner" Name="Owners" TextField="Text" IdField="Id"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public List<ResourceData> OwnersData { get; set; } = new List<ResourceData>
        {
            new ResourceData{ Text = "Nancy", Id = 1 },
            new ResourceData{ Text = "Steven", Id = 2 }
        };
        public class AppointmentData
        {
            public int Id { get; set; }
            public string Subject { get; set; }
            public DateTime StartTime { get; set; }
            public DateTime EndTime { get; set; }
            public int OwnerId { get; set; }
        }
        public class ResourceData
        {
            public int Id { get; set; }
            public string Text { get; set; }
        }
    }

    Constructors

    ScheduleResource()

    Declaration
    public ScheduleResource()

    Properties

    AllowMultiple

    Gets or sets a value indicating whether to allow multiple selection of resource names, which results in multiple instances of the same appointment for the selected resources.

    Declaration
    public bool AllowMultiple { get; set; }
    Property Value
    Type Description
    System.Boolean

    true to allow multiple selection of resource names. The default value is fasle.

    ChildContent

    Gets or sets the child content for schedule resource.

    Declaration
    public RenderFragment ChildContent { get; set; }
    Property Value
    Type Description
    Microsoft.AspNetCore.Components.RenderFragment

    The value used to build the content.

    Examples

    In the below example SfDataManager is rendered as child content to bind resource data using custom adaptor.

    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" Field="OwnerId" Title="Owner" Name="Owners" TextField="Text" IdField="Id">
                <SfDataManager AdaptorInstance="@typeof(CustomAdaptor)" Adaptor="Adaptors.CustomAdaptor"></SfDataManager>
            </ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code{
        public class CustomAdaptor : DataAdaptor
        {
            List<ResourceData> EventData = ResourceList();
            public async override Task<object> ReadAsync(DataManagerRequest dataManagerRequest, string key = null)
            {
                await Task.yield();
                return dataManagerRequest.RequiresCounts ? new DataResult() { Result = EventData, Count = EventData.Count() } : (object)EventData;
            }
        }
        private static List<ResourceData> LastResourceList()
        {
            return new List<ResourceData>
            {
                new ResourceData { Text = "Resource 1", Id = 1 },
                new LastLevel { Text = "Resource 2", Id = 2 },
                new LastLevel { Text = "Resource 3", Id = 3 }
            }
        }
        public class ResourceData
        {
            public int Id { get; set; }
            public string Text { get; set; }
        }
    }

    ColorField

    Gets or sets the mapping field for the Color field from the dataSource, used to specify the colors for the resources.

    Declaration
    public string ColorField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is Color.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" ColorField="ResColor"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            Public string ResColor { get; set;}
        }
    }

    CssClassField

    Gets or sets the mapping field for the CssClass field from the dataSource, used to specify different styles to each resource's appointments.

    Declaration
    public string CssClassField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is CssClass.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" CssClassField="CustomClass"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            Public string CustomClass { get; set;}
        }
    }

    DataSource

    Gets or sets the collection of resources to display in the scheduler.

    Declaration
    public IEnumerable<TItem> DataSource { get; set; }
    Property Value
    Type Description
    System.Collections.Generic.IEnumerable<TItem>

    The collection should be of type System.Collections.Generic.IEnumerable<>.

    EndHourField

    Gets or sets the mapping field for the EndHour field from the dataSource, used to specify different work end hours for each resource.

    Declaration
    public string EndHourField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is EndHour.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" EndHourField="ResEndHour"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            Public string ResEndHour { get; set;}
        }
    }

    ExpandedField

    Gets or sets the mapping field for the Expanded field from the dataSource, used to specify whether each resource level in the timeline view should be maintained in an expanded or collapsed state by default.

    Declaration
    public string ExpandedField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is Expanded.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" ExpandedField="Expand"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            Public string Expand { get; set;}
        }
    }

    Field

    Gets or sets a value that is bound to the resource field of appointment data.

    Declaration
    public string Field { get; set; }
    Property Value
    Type Description
    System.String

    This value should be a string and will be mapped in the ScheduleEventSettings<TValue> data source. The default value is null.

    Remarks

    If the resource field value is not mapped to the appointment data model, then the appointment will not be rendered for that resource.

    Examples

    In the below code example, ResourceId field is mapped for Field property to map the resource id for appointments.

    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" Field="ResourceId"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class AppointmentData
        {
            public int Id { get; set; }
            public string Subject { get; set; }
            public DateTime StartTime { get; set; }
            public DateTime EndTime { get; set; }
            public int ResourceId { get; set; }
        }
        public class ResourceData
        {
            public int Id { get; set; }
            public string Text { get; set; }
        }
    }

    GroupIDField

    Gets or sets the mapping field for the GroupID field from the dataSource, used to specify under which parent resource the child should be grouped.

    Declaration
    public string GroupIDField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is GroupID.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" GroupIDField="ResGroupId"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            Public string ResGroupId { get; set;}
        }
    }

    IdField

    Gets or sets the mapping field for the Id field from the dataSource, used to uniquely identify the resources.

    Declaration
    public string IdField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is Id.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" IdField="ResId"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            public int ResId { get; set; }
        }
    }

    Name

    Gets or sets a unique resource name for differentiating various resource objects while grouping.

    Declaration
    public string Name { get; set; }
    Property Value
    Type Description
    System.String

    This value should be a string and will be applied to the Resources property to group the resources. The default value is null.

    Examples

    In the below code example, Resource names were mapped for resource grouping.

    <SfSchedule TValue="AppointmentData">
        <ScheduleGroup Resources="@Resources"></ScheduleGroup>
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" Name="Rooms"></ScheduleResource>
            <ScheduleResource TItem="ResourceData" TValue="int" Name="Owners"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public string[] Resources { get; set; } = { "Rooms", "Owners" };
    }

    Query

    Gets or sets the external Query that will be executed during data processing.

    Declaration
    public Query Query { get; set; }
    Property Value
    Type Description
    Query

    Accepts Query value.

    StartHourField

    Gets or sets the mapping field for the StartHour field from the dataSource, used to specify different work start hours for each resource.

    Declaration
    public string StartHourField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is StartHour.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" StartHourField="ResStart"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            public string ResStart { get; set; }
        }
    }

    TextField

    Gets or sets the mapping field for the Text field from the dataSource, used to specify the resource names.

    Declaration
    public string TextField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is Text.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" TextField="ResName"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            public string ResName { get; set; }
        }
    }

    Title

    Gets or sets the title for the resource field to be displayed on the schedule event editor window.

    Declaration
    public string Title { get; set; }
    Property Value
    Type Description
    System.String

    This value should be a string and will be displayed on the editor window. The default value is null.

    WorkDaysField

    Gets or sets the mapping field for the WorkDays field from the dataSource, used to specify different working days for each resource.

    Declaration
    public string WorkDaysField { get; set; }
    Property Value
    Type Description
    System.String

    Accepts string value that should be mapped in the dataSource. The default value is WorkDays.

    Examples
    <SfSchedule TValue="AppointmentData">
        <ScheduleResources>
            <ScheduleResource TItem="ResourceData" TValue="int" WorkDaysField="ResWorkDays"></ScheduleResource>
        </ScheduleResources>
    </SfSchedule>
    @code {
        public class ResourceData
        {
            public int[] ResWorkDays { get; set; }
        }
    }

    Methods

    BuildRenderTree(RenderTreeBuilder)

    Declaration
    protected override void BuildRenderTree(RenderTreeBuilder __builder)
    Parameters
    Type Name Description
    Microsoft.AspNetCore.Components.Rendering.RenderTreeBuilder __builder

    OnInitializedAsync()

    Declaration
    protected override Task OnInitializedAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task
    Overrides
    SfDataBoundComponent.OnInitializedAsync()

    OnParametersSetAsync()

    Declaration
    protected override Task OnParametersSetAsync()
    Returns
    Type Description
    System.Threading.Tasks.Task
    Overrides
    SfDataBoundComponent.OnParametersSetAsync()

    Implements

    IScheduleResources
    Back to top Generated by DocFX
    Copyright © 2001 - 2023 Syncfusion Inc. All Rights Reserved