-
Notifications
You must be signed in to change notification settings - Fork 81
Added new kb article datepicker-kb-change-starting-day-of-week #2401
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 5 commits into
master
from
new-kb-datepicker-kb-change-starting-day-of-week-b9e5bc96f103437ea76aa38ac11df18f
Oct 10, 2024
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
3a40560
Added new kb article datepicker-kb-change-starting-day-of-week
ce54e9d
docs(DatePicker): kb polish
Tsvetomir-Hr d979ad0
Update knowledge-base/datepicker-kb-change-starting-day-of-week.md
Tsvetomir-Hr b8a6d05
Update knowledge-base/datepicker-kb-change-starting-day-of-week.md
Tsvetomir-Hr 34f5a96
Update knowledge-base/datepicker-kb-change-starting-day-of-week.md
Tsvetomir-Hr 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
60 changes: 60 additions & 0 deletions
60
knowledge-base/datepicker-kb-change-starting-day-of-week.md
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,60 @@ | ||
| --- | ||
| title: How to Change the Default Starting Day of the Week | ||
| description: Learn how to set the first day of the week to different from the default one in the Telerik Blazor DatePicker component by modifying the current culture settings. | ||
| type: how-to | ||
| page_title: How to Change the Default Starting Day of the Week | ||
| slug: datepicker-kb-change-starting-day-of-week | ||
| tags: datepicker, blazor, cultureinfo, firstdayofweek | ||
| res_type: kb | ||
| ticketid: 1665695 | ||
| --- | ||
|
|
||
| ## Environment | ||
| <table> | ||
| <tbody> | ||
| <tr> | ||
| <td>Product</td> | ||
| <td>DatePicker for Blazor, Calendar for Blazor</td> | ||
| </tr> | ||
| </tbody> | ||
| </table> | ||
|
|
||
| ## Description | ||
|
|
||
| This KB article answers the following questions: | ||
| * How can I change the first day of the week in the DatePicker? | ||
| * Is it possible to set different day as the start of the week from the default one in the Telerik DatePicker for Blazor? | ||
Tsvetomir-Hr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * What steps should I follow to modify the start of the week in a DatePicker component? | ||
|
|
||
| ## Solution | ||
|
|
||
| To set the start of the week to dfferent one in the Telerik DatePicker for Blazor, override the `FirstDayOfWeek` property of the current culture in your application. Follow the steps below to implement this solution: | ||
Tsvetomir-Hr marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| 1. Include the necessary namespaces for [globalization]({%slug globalization-formats%}) in your component. | ||
| 2. Add the Telerik DatePicker component to your razor page. | ||
| 3. Override the `OnInitialized` method to change the current culture's `FirstDayOfWeek` to the desired one. | ||
|
|
||
| ````CSHTML | ||
|
|
||
| @using System.Globalization | ||
|
|
||
| <TelerikDatePicker @bind-Value="@Date"/> | ||
|
|
||
| @code { | ||
| private DateTime Date { get; set; } = DateTime.Now; | ||
|
|
||
| protected override void OnInitialized() | ||
| { | ||
| var cultureInfo = new CultureInfo("en-US"); | ||
| cultureInfo.DateTimeFormat.FirstDayOfWeek = DayOfWeek.Monday; | ||
| CultureInfo.DefaultThreadCurrentCulture = cultureInfo; | ||
| CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; | ||
| } | ||
| } | ||
| ```` | ||
|
|
||
| By setting the `FirstDayOfWeek` property to `DayOfWeek.Monday`, the DatePicker will start the week with Monday based on the modified culture settings. | ||
|
|
||
| ## See Also | ||
|
|
||
| - [DatePicker Overview Documentation]({%slug components/datepicker/overview%}) | ||
Tsvetomir-Hr marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Oops, something went wrong.
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.