Our powerful JS Calendar component


Post by janiquekamgx »

Hello Bryntum team,

I would need an assistance on the following:

Given this code:

<BryntumCalendar
              {...calendarConfig}
              ref={calendarRef}
              onDateRangeChange={e => onDateRangeChange(e, setViewDate)}
              eventTooltipFeature={eventTooltip}
             
/>

Is there a way to intercept the mode change so that I can add some conditions which will prevent from changing to that mode if those conditions are not met yet?

For example:

  1. I have 3 views: Day, Week and 2 Weeks.
  2. I'm on week view;
  3. I click on the 2 weeks view, but some conditions are not met, -> return to previously selected view

I've tried using onActiveItemChange, but it seems like it is too late at this stage.

Thanks in advance!


Post by ghulam.ghous »

Hi,

To intercept and potentially prevent a mode change in the Bryntum Calendar, you can use the beforeActiveItemChange event. This event is fired before the view change is initiated, allowing you to check your conditions and return false to prevent the change if necessary.

Here's an example of how you might implement this:

const calendarProps = {
    listeners: {
        beforeActiveItemChange({ item }) {
            // Check your conditions here
            if (!conditionsMet) {
                return false; // Prevent the mode change
            }
        }
    },
    // other props
};

<BryntumCalendar {...calendarProps} ref={calendarRef} />

Make sure your conditions are properly defined in the conditionsMet variable or function. This approach should allow you to control the mode change based on your specific requirements.

https://bryntum.com/products/calendar/docs/#Calendar/view/Calendar#event-beforeActiveItemChange

Regards,


Post by janiquekamgx »

Thanks Ghulam,

This prevents from changing the mode.


Post by janiquekamgx »

Hello,

Just one more question: Even though the mode is not active, because the conditions are not met, the button is still 'pressed'. Can this also be avoided?


Post by Animal »

This seems like a bug. Let me check...


Post by Animal »

It is indeed a bug. We will have this fixed in the next version: https://github.com/bryntum/support/issues/11265


Post by janiquekamgx »

Thanks Ghulam and Animal, for the support.
Do you have an estimate on when the new version will be available?


Post by Animal »

We want to try to get 6.2.2 out very soon, we have some urgent fixes in it. I hope this week.


Post Reply