Skip to content

Commit 1321d81

Browse files
docs(Scheduler): Add resource grouping header template documentation (#2381)
* docs(Scheduler): Add resource grouping header template documentation * Update components/scheduler/templates/resource-grouping-header.md Co-authored-by: Nadezhda Tacheva <73842592+ntacheva@users.noreply.github.com> * Update components/scheduler/templates/resource-grouping-header.md Co-authored-by: Nadezhda Tacheva <73842592+ntacheva@users.noreply.github.com> * Update components/scheduler/templates/resource-grouping-header.md Co-authored-by: Nadezhda Tacheva <73842592+ntacheva@users.noreply.github.com> * update after review --------- Co-authored-by: Nadezhda Tacheva <73842592+ntacheva@users.noreply.github.com>
1 parent 601d933 commit 1321d81

File tree

4 files changed

+179
-3
lines changed

4 files changed

+179
-3
lines changed

components/scheduler/templates/appointment.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,5 +137,5 @@ You can also style the entire appointments by adding a class to their wrapping e
137137

138138
## See Also
139139

140-
* [Live Demo: Scheduler Templates](https://demos.telerik.com/blazor-ui/scheduler/templates)
140+
* [Live Demo: Scheduler Templates](https://demos.telerik.com/blazor-ui/scheduler/appointment-templates)
141141

components/scheduler/templates/dateheader.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,5 @@ The `DateHeaderTemplate` can be defined for the [day and week Scheduler views]({
100100

101101
## See Also
102102

103-
* [Live Demo: Scheduler Templates](https://demos.telerik.com/blazor-ui/scheduler/templates)
103+
* [Live Demo: Scheduler Templates](https://demos.telerik.com/blazor-ui/scheduler/dateheader-templates)
104104

Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
1+
---
2+
title: Resource Grouping Header
3+
page_title: Scheduler - Resource Grouping Header Template
4+
description: Use custom resource grouping header rendering through a template in the scheduler for Blazor.
5+
slug: scheduler-templates-resource-grouping-header
6+
tags: telerik,blazor,scheduler,templates,resource,grouping,header
7+
published: True
8+
position: 13
9+
---
10+
11+
# Resource Grouping Header Templates
12+
13+
You can use the `SchedulerResourceGroupHeaderTemplate` to customize the rendering of the Scheduler resource grouping header cells. This allows you to change the appearance of the content, add custom content or any HTML elements.
14+
15+
The `SchedulerResourceGroupHeaderTemplate`:
16+
* Is invoked for each resource when the Scheduler is configured to have resources and grouping.
17+
* Applies in both horizontal and vertical grouping.
18+
* Can be defined at the root level of the Scheduler and individually for each [Scheduler views]({%slug scheduler-views-overview%}). When configured at the root, the template applies to all views. If a `SchedulerResourceGroupHeaderTemplate` is defined at the view level, it will override the root-level template for that specific view.
19+
20+
The `context` of the template is a `SchedulerResourceGroupHeaderTemplateContext` object that contains:
21+
22+
| Property | Type | Description |
23+
| --- | --- | --- |
24+
| `Text` | `string` | The group text. |
25+
| `Value` | `object` | The resource value.|
26+
| `Field` | `string` | The field of the resource. |
27+
28+
>caption Example of using the SchedulerResourceGroupHeaderTemplate
29+
30+
````CSHMTL
31+
<TelerikScheduler Data="@Appointments"
32+
@bind-Date="@StartDate"
33+
Height="600px"
34+
Width="900px">
35+
<SchedulerResourceGroupHeaderTemplate>
36+
Text: @context.Text
37+
<br />
38+
Value: @context.Value
39+
<br />
40+
Field: @context.Field
41+
<br />
42+
</SchedulerResourceGroupHeaderTemplate>
43+
<SchedulerViews>
44+
<SchedulerDayView StartTime="@DayStart">
45+
<SchedulerResourceGroupHeaderTemplate>
46+
<p>
47+
@{
48+
if ((int)context.Value == 1)
49+
{
50+
<span title="The big meeting room is on 2nd floor." class="tooltip-target">
51+
<TelerikSvgIcon Icon="SvgIcon.InfoCircle"></TelerikSvgIcon>
52+
</span>
53+
}
54+
else
55+
{
56+
<span title="The small meeting room is on 3rd floor." class="tooltip-target">
57+
<TelerikSvgIcon Icon="SvgIcon.InfoCircle"></TelerikSvgIcon>
58+
</span>
59+
}
60+
}
61+
@context.Text
62+
</p>
63+
</SchedulerResourceGroupHeaderTemplate>
64+
</SchedulerDayView>
65+
<SchedulerWeekView StartTime="@DayStart" />
66+
<SchedulerMultiDayView StartTime="@DayStart" />
67+
<SchedulerMonthView></SchedulerMonthView>
68+
</SchedulerViews>
69+
<SchedulerResources>
70+
<SchedulerResource Field="@nameof(AppointmentModel.RoomId)" TextField="Name" ValueField="Id" Data="@Rooms"></SchedulerResource>
71+
</SchedulerResources>
72+
<SchedulerSettings>
73+
<SchedulerGroupSettings Resources="@GroupingResources" Orientation="@SchedulerGroupOrientation.Horizontal"></SchedulerGroupSettings>
74+
</SchedulerSettings>
75+
</TelerikScheduler>
76+
77+
<TelerikTooltip TargetSelector=".tooltip-target" />
78+
79+
@code {
80+
private List<string> GroupingResources = new List<string> { "RoomId" };
81+
private DateTime today { get; set; }
82+
private DateTime StartDate { get; set; } = DateTime.Today;
83+
private DateTime DayStart { get; set; }
84+
private IEnumerable<AppointmentModel> Appointments { get; set; }
85+
private IEnumerable<RoomModel> Rooms { get; set; }
86+
87+
protected override void OnInitialized()
88+
{
89+
today = DateTime.Today;
90+
91+
DayStart = new DateTime(today.Year, today.Month, today.Day, 10, 00, 0);
92+
93+
Appointments = new List<AppointmentModel>()
94+
{
95+
new AppointmentModel
96+
{
97+
Title = "Board meeting",
98+
Description = "Q4 is coming to a close, review the details.",
99+
Start = new DateTime(today.Year, today.Month, today.Day, 10, 00, 0),
100+
End = new DateTime(today.Year, today.Month, today.Day, 11, 30, 0),
101+
RoomId = 1
102+
},
103+
new AppointmentModel
104+
{
105+
Title = "General meeting",
106+
Description = "Discuss general topics.",
107+
Start = new DateTime(today.Year, today.Month, today.Day, 14, 00, 0),
108+
End = new DateTime(today.Year, today.Month, today.Day, 15, 30, 0),
109+
RoomId = 1
110+
},
111+
new AppointmentModel
112+
{
113+
Title = "Planning meeting",
114+
Description = "Kick off the new project.",
115+
Start = new DateTime(today.Year, today.Month, today.Day + 2, 10, 30, 0),
116+
End = new DateTime(today.Year, today.Month, today.Day + 2, 12, 45, 0),
117+
RoomId = 2
118+
},
119+
new AppointmentModel
120+
{
121+
Title = "Meeting about upcoming changes",
122+
Description = "Discuss upcoming changes.",
123+
Start = new DateTime(today.Year, today.Month, today.Day + 1, 15, 30, 0),
124+
End = new DateTime(today.Year, today.Month, today.Day + 1, 16, 45, 0),
125+
RoomId = 2
126+
},
127+
new AppointmentModel
128+
{
129+
Title = "Team meeting",
130+
Description = "Plan the work in the team.",
131+
Start = new DateTime(today.Year, today.Month, today.Day + 1, 11, 30, 0),
132+
End = new DateTime(today.Year, today.Month, today.Day + 1, 12, 0, 0),
133+
RoomId = 1
134+
},
135+
};
136+
137+
Rooms = new List<RoomModel>()
138+
{
139+
new RoomModel { Id = 1, Name = "Big Meeting Room" },
140+
new RoomModel { Id = 2, Name = "Small Meeting Room" }
141+
};
142+
}
143+
144+
public class AppointmentModel
145+
{
146+
public Guid Id { get; set; }
147+
public DateTime Start { get; set; }
148+
public DateTime End { get; set; }
149+
public string Title { get; set; }
150+
public string Description { get; set; }
151+
public int? RoomId { get; set; }
152+
public bool IsAllDay { get; set; }
153+
public string RecurrenceRule { get; set; }
154+
public int? RecurrenceId { get; set; }
155+
public string RecurrenceExceptions { get; set; }
156+
public string StartTimezone { get; set; }
157+
public string EndTimezone { get; set; }
158+
159+
public AppointmentModel()
160+
{
161+
Id = Guid.NewGuid();
162+
}
163+
}
164+
165+
public class RoomModel
166+
{
167+
public int Id { get; set; }
168+
public string Name { get; set; }
169+
}
170+
}
171+
````
172+
173+
## See Also
174+
175+
* [Live Demo: Scheduler Templates](https://demos.telerik.com/blazor-ui/scheduler/resourcegroupheader-templates)
176+

components/scheduler/templates/slot.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,5 +310,5 @@ The `context` of the template is a `SchedulerSlotTemplateContext` object that co
310310

311311
## See Also
312312

313-
* [Live Demo: Scheduler Templates](https://demos.telerik.com/blazor-ui/scheduler/templates)
313+
* [Live Demo: Scheduler Templates](https://demos.telerik.com/blazor-ui/scheduler/slot-templates)
314314

0 commit comments

Comments
 (0)