This is a migrated thread and some comments may be shown as answers.
Set datepicker default view to year selection
3 Answers 75 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Greg
Top achievements
Rank 1
Greg asked on 01 Jun 2011, 01:43 PM
How to change datepicker default view to year selection?

3 Answers, 1 is accepted

Sort by
0
Manoj Sharma*
Top achievements
Rank 1
answered on 13 Jun 2011, 02:32 PM
I need an answer too..
0
Atanas Korchev
Telerik team
answered on 13 Jun 2011, 02:55 PM
Hello,

 This is not currently supported by the datepicker. The day view is always selected by default.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Niko
Top achievements
Rank 1
answered on 23 Apr 2012, 01:19 PM
Well, after some work this seems to be actually a viable workaround for this limitation.
<%= Html.Telerik().DatePicker().Name("Picker1").ClientEvents(events => events.OnOpen("Picker1_Open")) %>

function Picker1_Open(e) {
    e.preventDefault();
    e.stopPropagation();
    var picker = $(this).data("tDatePicker");
    var calendar = picker.dateView._getCalendar();
    picker.open();
    if (!this.value) { // only show year first when no date selected
        var myDate = new Date();
        myDate = new Date(myDate.getFullYear() - 50, myDate.getMonth(), 1)
        var stopAnimBU = calendar.stopAnimation;
        calendar.stopAnimation = true;
        calendar.navigateVertically(3, myDate, false);
        calendar.stopAnimation = stopAnimBU;
    }
}
Tags
Date/Time Pickers
Asked by
Greg
Top achievements
Rank 1
Answers by
Manoj Sharma*
Top achievements
Rank 1
Atanas Korchev
Telerik team
Niko
Top achievements
Rank 1
Share this question
or