Show out of range years in datePicker

1 Answer 173 Views
Date/Time Pickers
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Lee asked on 20 Jan 2023, 09:23 PM | edited on 20 Jan 2023, 09:25 PM

In my date picker, I have a range of available dates from 1/1/2022 - 12/31/2024. When I open the date picker and drill back to the years they look out of place because the first three cells which were likely reserved for 2019 - 2021 are blank. 2022 starts in the middle of the picker and 2024 wraps to the next line. There is a feature with the months to display the disabled days using month.empty and passing an HTML string. I don't see anything like that for year though. Is there either a way to show disabled years or to start with the first year in the first cell of the first row? 

$("#myDatePicker").kendoDatePicker({
        month: {
            empty: '<span class="k-state-disabled">#= data.value #</span>'
        },
        // I'd like to do something like the below key:year: {
            empty: '<span class="k-state-disabled">#= data.value #</span>'
        },
        dateInput: true,
        start: "month",
        depth: "month",
        min: new Date(2022, 0, 1),
        max: new Date(2024, 11, 31),
        format: "d"
    })

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 25 Jan 2023, 01:41 PM

Hi Lee,

I am afraid a template for the items in the year view is currently not available. If you consider this feature important for you I recommend submitting it to our Feedback portal:

A possible workaround is to avoid setting min and max and manually append the .k-disabled CSS class to the months that fall out of the desired range. Please refer to the following Dojo dem oI prepared to demonstrate this:

Please note that the above implementation is not official and side effects might occur upon further testing and using the component with it.

Regards,
Nikolay
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Tags
Date/Time Pickers
Asked by
Lee
Top achievements
Rank 2
Bronze
Bronze
Bronze
Answers by
Nikolay
Telerik team
Share this question
or