You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: components/calendar/events.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,8 @@ This article explains the events available in the Telerik Calendar for Blazor:
15
15
*[ValueChanged](#valuechanged)
16
16
*[DateChanged](#datechanged)
17
17
*[ViewChanged](#viewchanged)
18
+
*[RangeStartChanged](#rangestartchanged)
19
+
*[RangeEndChanged](#rangeendchanged)
18
20
19
21
## ValueChanged
20
22
@@ -76,6 +78,72 @@ When handling the `ViewChanged` event, you cannot use two-way binding for the `V
76
78
77
79
>tip You are not required to provide an initial value to the `View` parameter. It will default to `CalendarView.Month`.
78
80
81
+
## RangeStartChanged
82
+
83
+
The `RangeStartChanged` fires every time the user selects a new starting date for the range of dates. The first click on a date in the Calendar will always be the starting date and the range can be consisted of dates only onwards.
84
+
85
+
## RangeEndChanged
86
+
87
+
The `RangeEndChanged` fires every time when the selection of dates is finished.
88
+
89
+
>caption Example of `Range` Selection with `RangeStartChanged` and `RangeEndChanged` events
90
+
91
+
````CSHTML
92
+
@* Observe the behavior of the RangeStartChanged and RangeEndChanged events and adding the selected dates to a List *@
93
+
94
+
<div class="example-wrapper">
95
+
<h4>Range Selection Initial Selection</h4>
96
+
97
+
<TelerikCalendar Views="3"
98
+
Date="@Date"
99
+
RangeStart="@RangeStart"
100
+
RangeEnd="@RangeEnd"
101
+
SelectionMode="@CalendarSelectionMode.Range"
102
+
RangeStartChanged="@StartChangeHandler"
103
+
RangeEndChanged="@EndChangeHandler">
104
+
</TelerikCalendar>
105
+
</div>
106
+
107
+
@if (SelectedDates.Any())
108
+
{
109
+
<div class="mt-3">
110
+
<h5 class="text-info">Selected dates:</h5>
111
+
@foreach (var day in SelectedDates)
112
+
{
113
+
<p class="text-muted">@day</p>
114
+
}
115
+
</div>
116
+
}
117
+
118
+
@code {
119
+
public DateTime Date { get; set; } = new DateTime(2020, 3, 1);
120
+
public DateTime RangeStart { get; set; } = new DateTime(2020, 3, 14);
121
+
public DateTime RangeEnd { get; set; } = new DateTime(2020, 3, 18);
122
+
public List<DateTime> SelectedDates { get; set; } = new List<DateTime>();
123
+
124
+
public void StartChangeHandler(DateTime startDate)
125
+
{
126
+
RangeStart = startDate;
127
+
GetDates();
128
+
}
129
+
130
+
public void EndChangeHandler(DateTime endDate)
131
+
{
132
+
RangeEnd = endDate;
133
+
GetDates();
134
+
}
135
+
136
+
public void GetDates()
137
+
{
138
+
var datesInBetween = Enumerable.Range(0, 1 + RangeEnd.Subtract(RangeStart).Days)
0 commit comments