[DateRangePicker] Can i make some dates unselectable?

Forge Component
(7)
Published on 2019-01-02 by Niels Favreau
7 votes
Published on 2019-01-02 by Niels Favreau

I'm creating a system with date range picker i wanna make a list of dates unselectable, is this possible?

Frankley Gustavo Fernandes Mesquita wrote:

I'm creating a system with date range picker i wanna make a list of dates unselectable, is this possible?

Hello, 

When you try to that you need to define a Start Date and End Date to analyze that period of time, right?

After that you can filter and remove from that list the dates that are selected. That looks OK to you?




Currently the component don't provide that functionality, since it was not a feature in the documentation from the JS library.
When i took a look at the github on how to achieve this you will need to extend the component with the folowing parameter added:

The isInvalidDate setting allows you to disable dates on the calendars. You provide a function and it is passed each date in the calendar. Return true if it should be disabled.

$('#yourelement').daterangepicker({
  isInvalidDate: function(date) {
    //compare to your list of dates, return true if date is in the list
  }
});


I will add this in the future to the component whenever i have time, since it's quite a good feature to have.