Skip to content

Commit ac34dbf

Browse files
dimodidimodi
authored andcommitted
Polish KB
1 parent a85b1fe commit ac34dbf

File tree

1 file changed

+39
-58
lines changed

1 file changed

+39
-58
lines changed

knowledge-base/calendar-kb-customize-multiview-header.md

Lines changed: 39 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: Learn how to display the month name above each view in a MultiView
44
type: how-to
55
page_title: How to Customize Month Headers in Telerik UI for Blazor MultiView Calendar
66
slug: calendar-kb-customize-multiview-header
7-
tags: telerik, ui, blazor, calendar, multiview, customization, header, template
7+
tags: telerik, blazor, calendar, multiview
88
res_type: kb
99
ticketid: 1672888
1010
---
@@ -13,86 +13,67 @@ ticketid: 1672888
1313

1414
<table>
1515
<tbody>
16-
<tr>
17-
<td>Product</td>
18-
<td>Calendar for Blazor</td>
19-
</tr>
16+
<tr>
17+
<td>Product</td>
18+
<td>Calendar for Blazor</td>
19+
</tr>
2020
</tbody>
2121
</table>
2222

2323
## Description
2424

25-
I want to customize the header of a MultiView Calendar to display the month name above each view.
25+
How to customize the header of a MultiView Calendar to display the month name above each month view?
2626

2727
## Solution
2828

29-
To display the month name above each view in a MultiView Calendar, use the [`HeaderTemplate`]({%slug calendar-templates-header%}) of the TelerikCalendar and apply custom CSS for styling for label positioning. The following example demonstrates how to achieve this customization:
29+
To display the month name above each view in a MultiView Calendar, use the [`HeaderTemplate`]({%slug calendar-templates-header%}) of the TelerikCalendar and apply custom CSS for styling for label positioning. The following example demonstrates how to achieve this customization. Note that it is applicable only for a horizontal layout
3030

3131
>caption MultiView Calendar with Header Template.
3232
3333
````CSHTML
34-
@using System.Globalization;
34+
@using System.Globalization
3535
36-
<style>
37-
.my-header {
38-
inline-size: var(--INTERNAL--kendo-calendar-view-width, 256px);
39-
display: flex;
40-
justify-content: center;
41-
}
42-
</style>
43-
44-
<TelerikCalendar @bind-Date="@StartDate" Views="@ViewCount"
45-
@bind-Value="@Value"
46-
@bind-View="@View"
36+
<TelerikCalendar @bind-Date="@CalendarDate"
4737
SelectionMode="@CalendarSelectionMode.Single"
48-
@ref="CalendarRef">
38+
@bind-Value="@CalendarValue"
39+
@bind-View="@CalendarView"
40+
Views="@ViewCount">
4941
<HeaderTemplate>
50-
@for (int i = 0; i < ViewCount; i++)
51-
{
52-
var monthNumber = Value.Month + i > 12 ? (Value.Month + i) % 12 : Value.Month + i;
53-
var month = CultureInfo.CurrentCulture.DateTimeFormat.GetAbbreviatedMonthName(monthNumber);
54-
<div class="my-header">@month</div>
55-
}
42+
<div class="month-names">
43+
@for (int i = 0; i < ViewCount; i++)
44+
{
45+
int monthNumber = CalendarValue.Month + i > 12 ? (CalendarValue.Month + i) % 12 : CalendarValue.Month + i;
46+
string month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(monthNumber);
47+
48+
<div>@month</div>
49+
}
50+
</div>
5651
</HeaderTemplate>
5752
</TelerikCalendar>
5853
59-
@code {
60-
private int ViewCount = 4;
61-
private DateTime StartDate = DateTime.Today;
62-
private DateTime Value = DateTime.Today;
63-
private CalendarView View = CalendarView.Month;
64-
private TelerikCalendar CalendarRef { get; set; }
65-
66-
private string GetMeetingClass(DateTime date)
67-
{
68-
if (date.Day % 5 == 0)
69-
{
70-
return "meeting";
71-
}
72-
else if (date.Day % 9 == 0)
73-
{
74-
return "cocktail";
75-
}
76-
else
77-
{
78-
return "";
79-
}
54+
<style>
55+
.month-names {
56+
width: 100%;
57+
display: flex;
58+
justify-content: space-between;
59+
8060
}
81-
82-
private void NavigateToCurrentMonth()
83-
{
84-
CalendarRef.NavigateTo(DateTime.Today, CalendarView.Month);
61+
.month-names > div {
62+
flex: 1 1 auto;
63+
text-align: center;
8564
}
65+
</style>
8666
87-
private void GoToCenturyView()
88-
{
89-
View = CalendarView.Century;
90-
}
67+
@code {
68+
private int ViewCount { get; set; } = 3;
69+
private DateTime CalendarDate { get; set; } = DateTime.Today;
70+
private DateTime CalendarValue { get; set; } = DateTime.Today;
71+
private CalendarView CalendarView { get; set; } = CalendarView.Month;
9172
}
9273
````
9374

9475
## See Also
9576

96-
- [Calendar Overview](https://docs.telerik.com/blazor-ui/components/calendar/overview)
97-
- [Calendar Header Template](https://docs.telerik.com/blazor-ui/components/calendar/templates/header-template)
98-
- [Calendar Views](https://docs.telerik.com/blazor-ui/components/calendar/views)
77+
* [Calendar Overview](https://docs.telerik.com/blazor-ui/components/calendar/overview)
78+
* [Calendar Header Template](https://docs.telerik.com/blazor-ui/components/calendar/templates/header-template)
79+
* [Calendar Views](https://docs.telerik.com/blazor-ui/components/calendar/views)

0 commit comments

Comments
 (0)