New to Telerik UI for ASP.NET Core? Start a free 30-day trial
Selecting Week Days in the DatePicker
Environment
Product | Telerik UI for ASP.NET Core DatePicker |
Progress Telerik UI for ASP.NET Core version | Created with the 2022.3.913 version |
Description
How can I select the days of the week from the Telerik UI for ASP.NET Core DatePicker?
Solution
- Hide the initially rendered days of the week within the Popup Calendar of the DatePicker for Telerik UI for ASP.NET Core.
- Create a flag variable which will hold the days of the week.
- To select the days of the week, handle the
.MonthTemplate()
and pass the current date as an argument. - Within the function handler, parse the date argument to a
Date
object. To get the current day, use the.getDay()
method and obtain it from the previously defined flag variable.
Index.cshtml
@(Html.Kendo().DatePicker()
.Name("datepicker")
.Value(DateTime.Today)
.Footer("Today - #=kendo.toString(data, 'd') #")
.MonthTemplate(month => month.Content("#= getDays(date) #"))
)
For the complete implementation of the suggested approach, refer to the Telerik REPL example on selecting the days of the week within the DatePicker.