-
Notifications
You must be signed in to change notification settings - Fork 81
Added new kb article calendar-kb-customize-multiview-header #2625
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dimodi
merged 3 commits into
master
from
new-kb-calendar-kb-customize-multiview-header-8ae51e1ab6ac48df9e18d71ed4e57bbe
Dec 13, 2024
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --- | ||
| title: Customize Month Headers in MultiView Calendar | ||
| description: Learn how to display the month name above each view in a MultiView Calendar using a custom header template and CSS in Telerik UI for Blazor. | ||
| type: how-to | ||
| page_title: How to Customize Month Headers in Telerik UI for Blazor MultiView Calendar | ||
| slug: calendar-kb-customize-multiview-header | ||
| tags: telerik, blazor, calendar, multiview | ||
| res_type: kb | ||
| ticketid: 1672888 | ||
| --- | ||
|
|
||
| ## Environment | ||
|
|
||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>Calendar for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Description | ||
|
|
||
| How to customize the header of a MultiView Calendar to display the month name above each month view? | ||
|
|
||
| ## Solution | ||
|
|
||
| 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 | ||
|
|
||
| >caption MultiView Calendar with Header Template. | ||
|
|
||
| ````CSHTML | ||
| @using System.Globalization | ||
|
|
||
| <TelerikCalendar @bind-Date="@CalendarDate" | ||
| SelectionMode="@CalendarSelectionMode.Single" | ||
| @bind-Value="@CalendarValue" | ||
| @bind-View="@CalendarView" | ||
| Views="@ViewCount"> | ||
| <HeaderTemplate> | ||
| <div class="month-names"> | ||
| @for (int i = 0; i < ViewCount; i++) | ||
| { | ||
| int monthNumber = CalendarValue.Month + i > 12 ? (CalendarValue.Month + i) % 12 : CalendarValue.Month + i; | ||
| string month = CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName(monthNumber); | ||
|
|
||
| <div>@month</div> | ||
| } | ||
| </div> | ||
| </HeaderTemplate> | ||
| </TelerikCalendar> | ||
|
|
||
| <style> | ||
| .month-names { | ||
| width: 100%; | ||
| display: flex; | ||
| justify-content: space-between; | ||
|
|
||
| } | ||
| .month-names > div { | ||
| flex: 1 1 auto; | ||
| text-align: center; | ||
| } | ||
| </style> | ||
|
|
||
| @code { | ||
| private int ViewCount { get; set; } = 3; | ||
| private DateTime CalendarDate { get; set; } = DateTime.Today; | ||
| private DateTime CalendarValue { get; set; } = DateTime.Today; | ||
| private CalendarView CalendarView { get; set; } = CalendarView.Month; | ||
| } | ||
| ```` | ||
|
|
||
| ## See Also | ||
|
|
||
| * [Calendar Overview](https://docs.telerik.com/blazor-ui/components/calendar/overview) | ||
| * [Calendar Header Template](https://docs.telerik.com/blazor-ui/components/calendar/templates/header-template) | ||
| * [Calendar Views](https://docs.telerik.com/blazor-ui/components/calendar/views) | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.