Premium support for our pure JavaScript UI components


Post by til.schniese »

Hi,

I am using the calendar field with some working time intervals in my events. Additionally I am having an external UI, where I can change the intervals of the calendars. After changing them, I also need to update the calendar field of the related events. When doing this, I am always getting this error:

Bildschirmfoto 2021-09-23 um 13.57.48.png
Bildschirmfoto 2021-09-23 um 13.57.48.png (16.21 KiB) Viewed 754 times

I noticed, that everything is working fine, if I use a new id for the updated calendarModel, but not if the ids are equal.

Unfortunately I am not able to get a test case to run, but maybe you already have an idea, why this happens.

We are using the SchedulerPro vue component, and running on version 4.2.2.


Post by alex.l »

Hi til.schniese,

If not a test case, please share a code what exactly you did. How did you update intervals, calendar in events and when.

All the best,
Alex


Post by arcady »

After changing them, I also need to update the calendar field of the related events.

You should not reassign the same calendar IIRC. Changing calendar intervals is meant to trigger rescheduling automatically. Doesn't that work w/o reassigning calendar? As Alex said we need to see some code ideally.


Post by til.schniese »

Of course. Actually it is very simple.

First I am just loading my events with the initial calendar model:

await eventStore.loadDataAsync([{ startDate, duration, calendar: new CalendarModel({...}) }]);

Now I am changing the intervals of the calendar in an external UI, which then returns an updated CalendarModel, that has the same id as the old one, but updated intervals. To reflect the changes in the events, I am doing:

event.setCalendar(calendarModel)

When doing this I am getting the above error, when the ids are equal.

You should not reassign the same calendar IIRC. Changing calendar intervals is meant to trigger rescheduling automatically. Doesn't that work w/o reassigning calendar?

This would be the optimal solution, but I wasn't able to replace the whole intervals array of the old calendar model. Is this possible? I thought about using addInterval, but unfortunately there is no removeInterval.


Post by alex.l »

There is not public calendar.clearIntervals() exists. Will be public in the nearest release, thanks for notification.

But event.calendar.clearIntervals() and event.calendar.addIntervals([...]) (same as gantt.project.calendar manipulations) not requires any calendar re-assignment. Confirmed in our demo https://bryntum.com/examples/gantt/advanced/

I also tested the next

const calendar = gantt.project.calendar;
calendar.clearIntervals(); // UI is reflected immediately
gantt.project.setCalendar(calendar); // no needed, but checked in any errors.

// also works well
const task = gantt.eventStore.getAt(3);
const calendar = task.calendar;

calendar.clearIntervals(); // UI is reflected immediately
task.setCalendar(calendar); // no needed, but checked if any errors.

If you cloned calendar model before change it, it wont work if you used the same id, it should be unique.
If you still have problems, I'm afraid we need a test case to reproduce it.

All the best,
Alex


Post by til.schniese »

Alright thanks, I guess clearIntervals will do the job then!


Post Reply