New to Telerik UI for Blazor? Download free 30-day trial

Picking Only Months

Environment

Product DatePicker for Blazor

Description

An app needs to process data for the month - is there a way to use DatePicker and choose only the Month/Year? Displaying it is quite easy with Format.

Is it possible to get a DatePicker that shows a popup with only month/year selection?

Solution

You can use the BottomView to limit how far down the user can go to. If they can go down only to the Year view they will effectively select months.

You can also set a Format that shows the month and year only too.

Here is an example of both:

@selectedDate
<br />
<TelerikDatePicker @bind-Value="@selectedDate"
                   BottomView="@CalendarView.Year"
                   Format="MMM yy">
</TelerikDatePicker>

@code{
    DateTime selectedDate { get; set; } = DateTime.Now;
}
In this article
Not finding the help you need? Improve this article