Our powerful JS Calendar component


Post by alexandreprezio »

Hi,
We have been using Bryntum Scheduler Pro for a while and are currently implementing Bryntum Calendar. We would like to use our internal component (as we did with Scheduler) to manage the displayed horizon, instead Bryntum Header.

However, we are encountering a problem: the onDateChange and onDateRangeChange functions, which we use to update our component, do not seem to be working.

The example is quite simple. Here is our implementation:

return (
    <Container>
      <div className="flex-center-between">
        <HorizonCalendarViewer
          horizon={{ from: moment(horizon.start), to: moment(horizon.end) }}
          onPrevClick={() => togglePrevOrNext("prev")}
          onNextClick={() => togglePrevOrNext("next")}
          currentViewMode={selectedView == "agenda" ? "day" : selectedView}/>
          
<div className="flex-center"> <MultiButton variant="bordered" size="sm"> <Button onClick={() => handleChangeView("week")} active={selectedView === "week"}> <span>Week</span> </Button> <Button onClick={() => handleChangeView("month")} active={selectedView === "month"}> <span>Month</span> </Button> <Button onClick={() => handleChangeView("agenda")} active={selectedView === "agenda"}> <span>Agenda</span> </Button> </MultiButton> </div> </div> <div className='calendar-container'> <BryntumCalendar height={600} ref={schedulerProRef} eventStore={eventStore} resourceStore={resourceStore} mode={selectedView} onDateChange={({ date, source, oldDate }) => { //No logs here console.log("onDateChange", date, source, oldDate); }} onDateRangeChange={({ old, source, new: { startDate, endDate } }) => { //No logs here console.log("onDateRangeChange", old, { startDate, endDate }, source); }} /> </div> </Container> )

We are unable to pass the onDateRangeChange stage as Scheduler Pro, so we cannot use our internal component at this stage.

Are there other handlers that I haven't seen in the documentation? Is this normal ?

Thank you very much for your help,


Post by marcio »

Hey alexandreprezio,

Thanks for reaching out.

Most likely the Calendar never receives a change request from your custom horizon component — onDateChange / onDateRangeChange fire when the Calendar instance actually changes its date / range, not when you update your own state. You have two options:

  • Drive the Calendar programmatically (recommended): keep a ref to the wrapper and call the Calendar API to move the view so it will emit the events. Example:

    const calendarRef = useRef();
    const togglePrevOrNext = dir => {
      const inst = calendarRef.current?.instance;
      if (!inst) return;
      if (dir === 'prev') inst.shiftPrevious();
      else inst.shiftNext();
    };
    
    <BryntumCalendar
      ref={calendarRef}
      onDateChange={...}
      onDateRangeChange={...}
    />
    
  • Or update the Calendar by changing its date prop (pass a new date/date range from state to the BryntumCalendar) so the wrapper will update the instance and trigger date/dateRange events.

Also, confirm your handler names are exactly onDateChange / onDateRangeChange (camelCase) and that you’re not preventing Calendar from updating elsewhere.

See Calendar dateRangeChange/event docs for reference: Calendar.dateRangeChange

If that doesn’t help, please paste your togglePrevOrNext implementation and how you hold the horizon state so we can suggest a more precise approach.

Best regards,
Márcio

How to ask for help? Please read our Support Policy


Post by alexandreprezio »

marcio wrote: Wed Sep 03, 2025 3:37 pm

Hey alexandreprezio,

Thanks for reaching out.

Most likely the Calendar never receives a change request from your custom horizon component — onDateChange / onDateRangeChange fire when the Calendar instance actually changes its date / range, not when you update your own state. You have two options:

  • Drive the Calendar programmatically (recommended): keep a ref to the wrapper and call the Calendar API to move the view so it will emit the events. Example:

    const calendarRef = useRef();
    const togglePrevOrNext = dir => {
      const inst = calendarRef.current?.instance;
      if (!inst) return;
      if (dir === 'prev') inst.shiftPrevious();
      else inst.shiftNext();
    };
    
    <BryntumCalendar
      ref={calendarRef}
      onDateChange={...}
      onDateRangeChange={...}
    />
    
  • Or update the Calendar by changing its date prop (pass a new date/date range from state to the BryntumCalendar) so the wrapper will update the instance and trigger date/dateRange events.

Also, confirm your handler names are exactly onDateChange / onDateRangeChange (camelCase) and that you’re not preventing Calendar from updating elsewhere.

See Calendar dateRangeChange/event docs for reference: Calendar.dateRangeChange

If that doesn’t help, please paste your togglePrevOrNext implementation and how you hold the horizon state so we can suggest a more precise approach.

Ah, perhaps I didn't express myself clearly, sorry. Actually, our togglePrevOrNext function already works and modifies the calendar status itself:

  const togglePrevOrNext = (type: "prev" | "next") => {
    if (type === "prev")
      calendarRef.current?.instance.shiftPrevious();
    else
      calendarRef.current?.instance.shiftNext();
  }

Sorry, I may have expressed myself poorly.

However, we wait for onDateRangeChange to return to update the “horizon” useState, to ensure that it is perfectly in line with the calendar status. Modifying the status manually risks poor synchronization.

But since onDateRangeChange is not triggered, either via our function or via Bryntum's base header, we cannot update this state.
Currently, we are not yet using setHorizon in the code because we are waiting for a return from onDateRangeChange, as we do in SchedulerPro.

Thank you


Post by marcio »

Hey alexandreprezio,

Thanks for clarifying.

I'm sharing a basic demo with some buttons that change the date range, and I see the functions getting called (as you can see in the attached screenshot).

Could you please adapt the demo to match your configuration and see if you can reproduce it, then send it back to us here?

Attachments
basic example.zip
(4.05 MiB) Downloaded 25 times
Screen Recording 2025-09-03 at 11.22.55.mov
(3.81 MiB) Downloaded 27 times

Best regards,
Márcio

How to ask for help? Please read our Support Policy


Post by Animal »

You can experiment with these things by using the Code Editor in live examples until you find what works that you can then take back to your app:

https://bryntum.com/products/calendar/examples/basic/

Screenshot 2025-09-03 at 16.38.12.png
Screenshot 2025-09-03 at 16.38.12.png (1.1 MiB) Viewed 1444 times

Post by alexandreprezio »

Okay, that's very strange... I just updated the Bryntum packages to version 6.3.1 (we were on 6.2.4), and that seems to have solved the problem. We didn't think to do that because I didn't see a fix like that in the release notes...
Well, it seems to be my fault. Sorry to have bothered you. I should have looked a little more before contacting you.
Thank you and have a good day.


Post by marcio »

Hey alexandreprezio,

Great to hear upgrading to 6.3.1 fixed it — no problem at all. If the issue returns or you need further assistance, please don't hesitate to contact us here on the forums. :)

Best regards,
Márcio

How to ask for help? Please read our Support Policy


Post Reply