How to disable the past in the calendar of dhtmlx scheduler
i tried below code but getting error as Object doesn’t support property or method ‘setSensitiveRange’
var calendar = scheduler.renderCalendar({
container: “datepickerID”,
navigation: true,
date: scheduler._date,
handler: function (date,calendar) {
}
});
var today=new Date();
calendar.setSensitiveRange(today, null);
To avoid switching to the past dates in the mini calendar, you need to redefine the default scheduler.updateCalendar
function in a next way:
var updateCalendar = scheduler.updateCalendar;
scheduler.updateCalendar = function(calendar, date){
var startLimit = scheduler.config.limit_start;
var endLimit = scheduler.config.limit_end;
var lastDayinMonth = new Date(date.getFullYear(), date.getMonth()+1, 0, 1);
if( (lastDayinMonth.getTime() < startLimit.getTime() ) || (date.getTime() > endLimit.getTime()) )
return false;
return updateCalendar.apply(this, arguments)
};
It will work if you also use limit_start
, limit_end
configs allow limiting the allowable date range in Scheduler (not in the mini calendar)
https://docs.dhtmlx.com/scheduler/api__scheduler_limit_start_config.html
If you don’t need it - just replace these configs with required dates.
Here is the snippet that demonstrates how it works
http://snippet.dhtmlx.com/5/4d96e4844