This is a migrated thread and some comments may be shown as answers.

Default Selection to Year

6 Answers 499 Views
Date/Time Pickers
This is a migrated thread and some comments may be shown as answers.
Matt
Top achievements
Rank 1
Matt asked on 06 Aug 2014, 09:49 PM
I have a Date of Birth field in the form.
It currently defaults to today's date.
The customer has requested that instead starting off showing the month view, that it start by showing the century, then select decade, then select year, then month, and then show the month view.

So basically he wants to to start the screen off in the screenshot I've shown attached to this this threat.

Basically I need it to work opposite what it currently does, where it starts off with month view, then go back to year view, then decade view, then century view.

6 Answers, 1 is accepted

Sort by
0
Dimiter Madjarov
Telerik team
answered on 07 Aug 2014, 10:08 AM
Hello Matthew,


You could achieve this with the start configuration option of the widget. Here is a runnable example, which demonstrates it in action.

I wish you a great day!

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Matt
Top achievements
Rank 1
answered on 07 Aug 2014, 01:47 PM
Perfect! I need it to default to last century though, not this one. Very few people have a birthday in the 21th Century.
0
Accepted
Dimiter Madjarov
Telerik team
answered on 07 Aug 2014, 02:55 PM
Hello Matthew,


The reason for this behavior is that the current property of the DatePicker is set to today's date, because there is no value specified. A sample workaround would be use the open event of the DatePicker, access the Calendar and set it's value to a date in the desired century. Here is the updated example.

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Matt
Top achievements
Rank 1
answered on 11 Aug 2014, 04:00 PM
I'm getting the following error:

TypeError: $(...).data(...) is undefined$(".birthDatePicker").data("kendoDatePicker").one("open", function(){ this.dateV...

This is how my code looks.

    $(".birthDatePicker").kendoDatePicker({ start: "century" });
    $(".birthDatePicker").data("kendoDatePicker").one("open", function(){ this.dateView.calendar.value(new Date(1990, 1, 1))});
0
Matt
Top achievements
Rank 1
answered on 11 Aug 2014, 04:05 PM
Nevermind, I got it to work by doing this:

$(".birthDatePicker").kendoDatePicker({ start: "century" }).data("kendoDatePicker").one("open", function(){ this.dateView.calendar.value(new Date(1990, 1, 1))});
0
Dimiter Madjarov
Telerik team
answered on 12 Aug 2014, 12:48 PM
Hello Matthew,


I am glad the issue is resolved.

Have a nice day!

Regards,
Dimiter Madjarov
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
Tags
Date/Time Pickers
Asked by
Matt
Top achievements
Rank 1
Answers by
Dimiter Madjarov
Telerik team
Matt
Top achievements
Rank 1
Share this question
or