Default Selection to Year

7 posts, 1 answers
  1. Matt
    Matt avatar
    7 posts
    Member since:
    Dec 2010

    Posted 06 Aug 2014 Link to this post

    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.
  2. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 07 Aug 2014 Link to this post

    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!
     
  3. Kendo UI is VS 2017 Ready
  4. Matt
    Matt avatar
    7 posts
    Member since:
    Dec 2010

    Posted 07 Aug 2014 in reply to Dimiter Madjarov Link to this post

    Perfect! I need it to default to last century though, not this one. Very few people have a birthday in the 21th Century.
  5. Answer
    Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 07 Aug 2014 Link to this post

    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!
     
  6. Matt
    Matt avatar
    7 posts
    Member since:
    Dec 2010

    Posted 11 Aug 2014 in reply to Dimiter Madjarov Link to this post

    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))});
  7. Matt
    Matt avatar
    7 posts
    Member since:
    Dec 2010

    Posted 11 Aug 2014 in reply to Matt Link to this post

    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))});
  8. Dimiter Madjarov
    Admin
    Dimiter Madjarov avatar
    2156 posts

    Posted 12 Aug 2014 Link to this post

    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!
     
Back to Top
Kendo UI is VS 2017 Ready