Class ScheduleResource<TValue, TItem>
A class that represents the resource related configurations and the options for binding its data.
Inheritance
Inherited Members
Namespace: Syncfusion.Blazor.Schedule
Assembly: Syncfusion.Blazor.dll
Syntax
public class ScheduleResource<TValue, TItem> : SfDataBoundComponent, IComponent, IHandleEvent, IHandleAfterRender, IDisposable, 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
[Parameter]
public bool AllowMultiple { get; set; }
Property Value
| Type | Description |
|---|---|
| bool |
|
ChildContent
Gets or sets the child content for schedule resource.
Declaration
[Parameter]
public RenderFragment ChildContent { get; set; }
Property Value
| Type | Description |
|---|---|
| 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
[Parameter]
public string ColorField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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
[Parameter]
public string CssClassField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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
[Parameter]
public IEnumerable<TItem> DataSource { get; set; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<TItem> | The collection should be of type IEnumerable<T>. |
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
[Parameter]
public string EndHourField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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
[Parameter]
public string ExpandedField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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
[Parameter]
public string Field { get; set; }
Property Value
| Type | Description |
|---|---|
| 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
[Parameter]
public string GroupIDField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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
[Parameter]
public string IdField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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
[Parameter]
public string Name { get; set; }
Property Value
| Type | Description |
|---|---|
| string | This value should be a string and will be applied to the Resources property to group the resources. The default value is |
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
[Parameter]
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
[Parameter]
public string StartHourField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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
[Parameter]
public string TextField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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
[Parameter]
public string Title { get; set; }
Property Value
| Type | Description |
|---|---|
| string | This value should be a string and will be displayed on the editor window. The default value is |
WorkDaysField
Gets or sets the mapping field for the WorkDays field from the dataSource, used to specify different working days for each resource.
Declaration
[Parameter]
public string WorkDaysField { get; set; }
Property Value
| Type | Description |
|---|---|
| string | Accepts string value that should be mapped in the dataSource. The default value is |
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 |
|---|---|---|
| RenderTreeBuilder | __builder |
Overrides
OnInitializedAsync()
Method invoked when the component is ready to start.
Declaration
protected override Task OnInitializedAsync()
Returns
| Type | Description |
|---|---|
| Task | A System.Threading.Tasks.Task representing any asynchronous operation. |
Overrides
OnParametersSetAsync()
Declaration
protected override Task OnParametersSetAsync()
Returns
| Type |
|---|
| Task |