Premium support for our pure JavaScript UI components


Post by til.schniese »

Hi there,

We are using Vue inline events in SchedulerPro. I noticed that the event duration is not correct when only updating the startDate of an event.

Example:

  • 1. Event has startDate = 3/12/22, endDate = 3/13/22
  • 2. I am changing the startDate to 3/11/22, but keep the endDate
  • 3. The event is now displayed from 3/11/22 to 3/12/22, instead of 3/11/22 to 3/13/22

I provide a reduced test case with the same example. By clicking the change button on top, the startDate will be changed and you can see the behavior.

We actually need this fixed as soon as possible!

Attachments
TestCaseVue.vue.zip
(1003 Bytes) Downloaded 29 times

Post by marcio »

Hi til.schniese,

I believe that there is a misunderstanding here. That's the expected behavior. That's because we have a duration field for events https://www.bryntum.com/docs/scheduler-pro/api/Scheduler/model/EventModel#field-duration

Assuming that 1. Event has startDate = 3/12/22, endDate = 3/13/22, we have that the duration of the event is 1 day.

If we change only the start date, the duration remains as 1 day, so that's why the end date is updated to 3/12/22.

If you want that the end date remains at 3/13/22, you'll need to update the duration of the event to 2 days, as it's the timespan between 3/11/22 and 3/13/22.

Best regards,
Márcio


Post by til.schniese »

Hi marcio,

I hear that. The point is that I don't provide the duration field in the inline data. If I understand it correctly, the duration is therefore calculated automatically from startDate and endDate. After I provide the new startDate, the duration should consequently automatically be updated to 2 days here.


Post by marcio »

Hey, actually the duration is calculated with the start/end dates provided on the first load. After that, you need to update the duration also to work as you mentioned. :)

Best regards,
Márcio


Post by til.schniese »

That's a bummer because taking care of the duration myself would be very inconvenient in my setup. The weird thing is that in the test case I provided, the duration will be automatically updated correctly when the change button is clicked twice (and there is no difference in the input - basically just repeating step 2 will produce a correct duration). Can you maybe check why the duration is calculated for the second change (with exact same dates) correctly, but not for the first change?


Post by arcady »

Hello,
There is a difference in Scheduler Pro when you provide an event startDate and endDate only.
When you provide endDate only its treated as the event resize, but when you provide startDate only it's treated as the event move operation.

If you want to change an event start and recalculate duration you can use https://www.bryntum.com/docs/scheduler-pro/api/SchedulerPro/model/EventModel#function-setStartDate method which accepts an additional keepDuration argument.

// move myEvent start 1 hour earlier and expand duration accordingly
myEvent.setStartDate(myEvent.startDate - 60 * 60 * 1000, false)

Worth mentioning that calling setStartDate will also trigger the change propagation
If you want to avoid that you can use putStartDate instead (it is not documented but that's just an issue in the docs it exists since the very beginning of the engine).

Best regards!


Post by til.schniese »

Hi arcady,

thanks for the reply. It is still not very convenient to use an additional set*method on the event here, because I am just using the inline events array. I am obviously not into your code. But I still have the feeling that this is something that could be changed for the inline data. The point of inline events is that I can use them as a single source of truth (at least this is what I expected), such that they always match the displayed events. But here, the scheduler produces a result, that is different from the events array, so I can't rely on the inline data anymore. Would it be possible to change the logic? The point is when changing startDate + endDate together, the duration is updated correctly. It feels strange, that the endDate will be overwritten with an old duration even though the correct endDate is provided in the inline data.


Post by alex.l »

Hi til.schniese,

I don't think that's possible to easily change this. This is expected behaviour: when startDate changed, event will be moved to new startDate but will keep duration. endDate change will keep startDate but update duration of the event.
To update startDate and duration together (in other words keep initial endDate), you can set startDate and endDate with 2 operations.

const initialEndDate = event.endDate;
event.startDate = newStartDate;
event.endDate = initialEndDate;

Or use approach that Arcady suggested.

All the best,
Alex


Post Reply