Skip to content

Commit 260ee74

Browse files
docs(calendar): navigate method
1 parent 273af48 commit 260ee74

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

components/calendar/navigation.md

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ position: 2
1010

1111
# Calendar Navigation
1212

13-
The user can navigate through several different views in a calendar - from a century, to a month. You can control in which view the user starts, the date which the calendar shows initially, and how deep the user can go.
13+
The user can navigate through several different views in a calendar - from a century, to a month. You can control in which view the user starts, the date which the calendar shows initially, how deep the user can go, and to also navigate to a desired date and view with code.
1414

1515
The calendar shows arrows that let the user flip between the adjacent periods. Clicking the `Today` button at the top navigates to a period in the current view that includes the current date.
1616

@@ -84,6 +84,33 @@ The selected date is: @selectedDate
8484
8585
![](images/up-down-navigation.gif)
8686

87+
## Programmatic Navigation
88+
89+
You can make the Calendar component move to a certain date and view through its `Navigate` method from your own code. The method takes into account the min and max dates, and the allowed views. If the parameters passed to the method are not allowed by those constraints, navigation will not occur.
90+
91+
>caption Navigate the Calendar to a date and view programmatically
92+
93+
````CSHTML
94+
@using Telerik.Blazor.Components.Calendar
95+
@using Telerik.Blazor.Components.Button
96+
97+
<TelerikButton OnClick="@NavigateCalendarProgrammatically">Go to new date and view</TelerikButton>
98+
<TelerikCalendar Date="@startDate" Max="@maxDate" Min="@minDate" View="@Telerik.Blazor.CalendarView.Decade" ref="@theCalendar"></TelerikCalendar>
99+
100+
@functions{
101+
DateTime startDate = new DateTime(2345, 11, 22);
102+
DateTime maxDate = new DateTime(2400, 11, 22);
103+
DateTime minDate = new DateTime(1800, 11, 22);
104+
105+
Telerik.Blazor.Components.Calendar.TelerikCalendar theCalendar;
106+
107+
void NavigateCalendarProgrammatically()
108+
{
109+
theCalendar.Navigate(DateTime.Now, Telerik.Blazor.CalendarView.Month);
110+
}
111+
}
112+
````
113+
87114
## See Also
88115

89116
* [Live Demo: Calendar](https://demos.telerik.com/blazor/calendar/index)

0 commit comments

Comments
 (0)