I'm working on configuring the Calendar to restrict users to a specific date range, preventing navigation outside of this range using both the date picker and the previous/next buttons.
I've set the MaxDate and MinDate in the calendar configuration and included these settings in the <bryntum-calendar>, but it hasn't worked as expected. Additionally, setting the agenda view results in an error. I have attached a screenshot of the error for your reference.
Is there an alternative method to achieve this functionality?
Try configuring your AgendaView with the following as a property:
afterStartDateSet : function(startDate, oldStartDate) {
const
me = this,
{ refreshCount } = me,
incomingEndDate = me.hasConfig('endDate') && me.peekConfig('endDate');
// If we are bounded by an endDate configuration, but are not in the process of being passed
// a new endDate (unless we are at configure time), keep the end date synced with current duration.
if (me.hasConfig('endDate') && (!incomingEndDate || me.isConfiguring)) {
const duration = DateHelper.diff(oldStartDate || startDate, me.endDate, 'day');
me.endDate = DateHelper.add(startDate, duration, 'day');
}
// If that changed the end date, the updater will have done a refresh.
// If there was no change to the endDate, so no refresh, we have to refresh here.
if (!me.isConfiguring && !incomingEndDate && me.refreshCount === refreshCount) {
me._cellMap?.clear();
me.refresh();
me.triggerRangeChange(startDate, me.endDate);
}
}
Screenshot 2024-08-14 at 13.53.28.png (300.34 KiB) Viewed 209 times
The minDate is 1 Oct 2020 We are going back to the previous week, and that goes from 27 Sep to 3 Oct.
A little bit will be outside the Calendar range. I propose that the validation specifies that a new navigation range is valid if any of it is within the Calendar's min/max range.
So this navigation will work in my fix branch. It doesn't in 6.0