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

Disabling datepicker dates

5 Answers 454 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Emar Wayne
Top achievements
Rank 1
Emar Wayne asked on 10 Jul 2018, 09:44 AM

Hi,

Is there a way to disable specific dates in the Datepicker component similar to the disableDates for kendo calendar in AngularJS?

Thanks,

Wayne

5 Answers, 1 is accepted

Sort by
0
Svet
Telerik team
answered on 11 Jul 2018, 07:12 AM
Hi Wayne,

Unfortunately, currently there is no such feature available as a built in functionality. 

If you have the time, please support the following feature request from our UserVoice portal by commenting and/or voting:
http://kendoui-feedback.telerik.com/forums/555517-kendo-ui-for-angular-feedback/suggestions/20593801-disable-certain-days-of-the-week-in-the-angular-2

I have also prepared an example using some custom JavaScript, that demonstrates, how we can apply a specific CSS class to a particular date (4 July 2018), so that it is disabled. Basically, on (open) event of the DatePicker we will get all td elements, that hold a date and if the title attribute of the td is equal to 'Wednesday, July 4, 2018', then we will add the '.disabled' class to the td. Check the following sample plunker demonstrating this approach:
https://plnkr.co/edit/vq30AdQVKTtYXOPQTYGV?p=preview

I hope this helps.

Regards,
Svetlin
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Emar Wayne
Top achievements
Rank 1
answered on 11 Jul 2018, 11:05 AM

Hi Svetlin,

Thank you for the swift response. Just tested it on the application and it works flawlessly!

Regards,

Wayne

0
Emar Wayne
Top achievements
Rank 1
answered on 12 Jul 2018, 12:46 PM

Hello Svetlin, upon further testing, I have noticed that the disabled dates revert back to being enabled whenever the datepicker is scrolled up (mouse scroll, keyboard navigation, etc.). At first I thought it was a problem persisting in my application but, I re-checked the link you provided and the problem occurs there as well. Can you please look into this?

Thanks,

Wayne

0
Accepted
Svet
Telerik team
answered on 13 Jul 2018, 01:30 PM
Hi Wayne,

We could further optimize the suggested approach by adding an event listener to the scrolling container that holds the months and their dates. So whenever we scroll we can add the disabled class to the required dates. Check the following updated sample plunker:
https://plnkr.co/edit/f32f4pKDf4zwVyshZdfJ?p=preview

However, do note, that the demonstrated functionality is not supported and it may not work as expected in all cases or cause some undesired effects.

Regards,
Svetlin
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Emar Wayne
Top achievements
Rank 1
answered on 16 Jul 2018, 06:19 AM

Hey Svetlin,

Thank you again for your response, it works perfectly now.

Regards,

Wayne

Tags
General Discussions
Asked by
Emar Wayne
Top achievements
Rank 1
Answers by
Svet
Telerik team
Emar Wayne
Top achievements
Rank 1
Share this question
or