Mini Calendar (Date Picker) - block navigation to dates outside a defined range


I use mini calendar with a scheduler in order to display a periode of a contrat. I want to block navigation on dates outside the periode of a contrat. How I can do this ?

I tried to block the date change with a condition. But, I would prefer to block the click on the date outstide the periode.

showMinical() {
    if (this.scheduler.isCalendarVisible())
        position: 'dhx_minical_icon',
        date: this.scheduler.getState().date,
        navigation: true,
        handler: (date) => {
          if(date >= this.contract.StartDate && date <= this.contract.EndDate)
<button mat-stroked-button type="button" id="btnCalendrier" (click)="showMinical()">
      <span class="menu-icon icon-calendar"></span>
      <span class="position-mini-cal" id="dhx_minical_icon">&nbsp;</span>

Thank you!


Unfortunately the built-in minicalendar does not provide such functionality, there are no API events or callback that would allow you to control what happens when you press arrow buttons to navigate between months.

As a workaround, you can override the scheduler.renderCalendar method, which is called each time the datepicker is repainted.
When the method is called - you call the original method in order to display the calendar, and then, depending on the date of the datepicker, you can remove one of navigation arrows to prevent user from switching dates in that direction.


// your project dates
const minProjectDate = new Date(2022, 1, 1);// 1st of February
const maxProjectDate = new Date(2022, 6, 1);// 1st of July (js months are zero-based)

// workaround
   const renderCalendar = scheduler.renderCalendar;
   scheduler.renderCalendar = function(config){
       const calendarDate = config && ? : scheduler.getState().date;

       const node = renderCalendar.apply(this, arguments);

       if( Date(calendarDate)).valueOf() <= 
            node.querySelector(".dhx_year_month .dhx_cal_prev_button").remove();
       if( Date(calendarDate)).valueOf() >= 
            node.querySelector(".dhx_year_month .dhx_cal_next_button").remove();

       return node;

Here is a complete demo: