Skip to content

Commit 8465d1d

Browse files
chore(calendar): updates for 2.0.0
1 parent 86ffca4 commit 8465d1d

File tree

5 files changed

+36
-32
lines changed

5 files changed

+36
-32
lines changed
-37.8 KB
Loading

components/calendar/navigation.md

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,12 @@ You can control how far the user can go by setting the `Min` and `Max` propertie
2424
The user starts in April 2019 and can navigate between January 2019 and July 2019.
2525
<br />
2626
27-
<TelerikCalendar Date="@startDate" View="@CalendarView.Month" Min="@minDate" Max="@maxDate"></TelerikCalendar>
27+
<TelerikCalendar @bind-Date="@startDate" @bind-View="@selectedView" Min="@minDate" Max="@maxDate"></TelerikCalendar>
2828
@code {
29-
DateTime startDate = new DateTime(2019, 4, 1);
30-
DateTime minDate = new DateTime(2019, 1, 1);
31-
DateTime maxDate = new DateTime(2019, 7, 31);
29+
DateTime startDate = new DateTime(2019, 4, 1);
30+
DateTime minDate = new DateTime(2019, 1, 1);
31+
DateTime maxDate = new DateTime(2019, 7, 31);
32+
CalendarView selectedView { get; set; } = CalendarView.Month;
3233
}
3334
````
3435

@@ -57,22 +58,23 @@ You can control how much detail the user can go into by setting the `BottomView`
5758
The user starts in the Decade view and can only go down to years.
5859
<br />
5960
60-
<TelerikCalendar BottomView="@CalendarView.Year" View="@CalendarView.Decade"
61-
Min="@min" Max="@max" ValueChanged="@MyValueChangeHandler">
61+
<TelerikCalendar BottomView="@CalendarView.Year" @bind-View="@SelectedView"
62+
Min="@min" Max="@max" ValueChanged="@MyValueChangeHandler">
6263
</TelerikCalendar>
6364
64-
The selected date is: @selectedDate
65+
<br />The selected date is: @selectedDate
6566
6667
@code {
67-
private DateTime min = new DateTime(2015, 1, 1);
68-
private DateTime max = new DateTime(2025, 12, 31);
69-
private string selectedDate = "";
70-
71-
private void MyValueChangeHandler(DateTime newValue)
72-
{
73-
selectedDate = newValue.ToString();
74-
StateHasChanged();
75-
}
68+
private DateTime min = new DateTime(2015, 1, 1);
69+
private DateTime max = new DateTime(2025, 12, 31);
70+
private CalendarView SelectedView { get; set; } = CalendarView.Decade;
71+
private string selectedDate = "";
72+
73+
private void MyValueChangeHandler(DateTime newValue)
74+
{
75+
selectedDate = newValue.ToString();
76+
StateHasChanged();
77+
}
7678
}
7779
````
7880

@@ -87,12 +89,10 @@ You can make the Calendar component move to a certain date and view through its
8789
>caption Navigate the Calendar to a date and view programmatically
8890
8991
````CSHTML
90-
Programmatic Calendar navigation<br />
92+
@* Programmatic Calendar navigation *@
9193
92-
<TelerikCalendar Date="@startDate"
93-
Min="@min"
94-
Max="@max"
95-
View="@calendarView">
94+
<TelerikCalendar @bind-Date="@startDate" @bind-View="@calendarView"
95+
Min="@min" Max="@max">
9696
</TelerikCalendar>
9797
<TelerikButton OnClick="@UpdateView">Update View</TelerikButton>
9898

components/calendar/overview.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ To use a Telerik Calendar for Blazor, add the `TelerikCalendar` tag.
1717
>caption Basic calendar with its key features, and ValueChanged event handling
1818
1919
````CSHTML
20-
Main Calendar features, ValueChanged event handling.<br />
20+
@* Main Calendar features, ValueChanged event handling. *@
21+
<br />
2122
22-
<TelerikCalendar Min="@min" Max="@max" ValueChanged="@MyValueChangeHandler" Date="@DateTime.Now">
23+
<TelerikCalendar Min="@min" Max="@max" ValueChanged="@MyValueChangeHandler" @bind-Date="@theDate">
2324
</TelerikCalendar>
2425
2526
<br />
@@ -29,14 +30,15 @@ The selected date is: @selectedDate
2930
3031
private DateTime min = new DateTime(2015, 1, 1);
3132
private DateTime max = new DateTime(2025, 12, 31);
33+
private DateTime theDate { get; set; } = DateTime.Now;
3234
private string selectedDate = "";
3335
3436
private void MyValueChangeHandler(DateTime newValue)
3537
{
3638
selectedDate = newValue.ToString("dd MMM yyyy");
37-
StateHasChanged();
3839
}
3940
}
41+
4042
````
4143

4244
>caption The result from the code snippet above

components/calendar/selection.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The user will not be able to select the first and second of April 2019.
4343
<h4>Single Selection</h4>
4444
4545
<TelerikCalendar SelectionMode="@CalendarSelectionMode.Single" ValueChanged="@SingleSelectionChangeHandler"
46-
DisabledDates="@DisabledDates" Date="@startDate">
46+
DisabledDates="@DisabledDates" @bind-Date="@startDate">
4747
</TelerikCalendar>
4848
<br />
4949
@if (selectedDate != null)
@@ -55,7 +55,7 @@ The user will not be able to select the first and second of April 2019.
5555
<h4>Multiple Selection</h4>
5656
5757
<TelerikCalendar SelectionMode="@CalendarSelectionMode.Multiple" ValueChanged="@MultipleSelectionChangeHandler"
58-
DisabledDates="@DisabledDates" Date="@startDate" @ref="multipleSelCalendar">
58+
DisabledDates="@DisabledDates" @bind-Date="@startDate" @ref="multipleSelCalendar">
5959
</TelerikCalendar>
6060
<br />
6161
@if (chosenDates != null && chosenDates.Count > 0)
@@ -69,29 +69,30 @@ The user will not be able to select the first and second of April 2019.
6969
}
7070
7171
@code {
72-
private DateTime startDate = new DateTime(2019, 4, 1);//set the initial date of the calendar
72+
private DateTime startDate = new DateTime(2019, 4, 1); // set the initial date of the calendar
7373
74-
//set dates the user can't select
74+
// set dates the user can't select
7575
private List<DateTime> DisabledDates = new List<DateTime>() { new DateTime(2019, 4, 1), new DateTime(2019, 4, 2) };
7676
77-
//fields to store and render the user selection
77+
// fields to store and render the user selection
7878
private DateTime? selectedDate { get; set; } = null;
7979
private List<DateTime> chosenDates { get; set; }
8080
8181
private void SingleSelectionChangeHandler(DateTime newValue)
8282
{
83-
//with single selection, the argument is a single DateTime object with the new selection
83+
// with single selection, the argument is a single DateTime object with the new selection
8484
selectedDate = newValue;
8585
}
8686
87-
//reference used to obtain the selected dates from a multiple selection calendar
87+
// reference used to obtain the selected dates from a multiple selection calendar
8888
private Telerik.Blazor.Components.TelerikCalendar multipleSelCalendar;
8989
private void MultipleSelectionChangeHandler()
9090
{
9191
//with multiple selection, get the selected dates from a component reference
9292
chosenDates = multipleSelCalendar.SelectedDates;
9393
}
9494
}
95+
9596
````
9697

9798

upgrade/breaking-changes/2-0-0.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,8 @@ This is a list of the components that had methods removed and the new approach o
6262

6363
### Calendar
6464

65-
* The `Navigate()` method is no longer available. Use binding for the `View` and `Date` parameters. An example is avalable in the [Navigate]({%slug components/calendar/navigation%}#programmatic-navigation) article.
65+
* The `Navigate()` method is no longer available in favor of two-way binding for the `View` and `Date` parameters. An example is avalable in the [Navigate]({%slug components/calendar/navigation%}#programmatic-navigation) article.
66+
* The `View` and `Date` parameters should be used with two-way binding. Otherwise, state changes (like selection) may revert them to the values set in the markup and move the user unexpectedly.
6667

6768
### DatePicker
6869

0 commit comments

Comments
 (0)