Discuss anything related to web development but no technical support questions


Post by lxxrxns »

Hi there,

I would like to know if it's possible to prevent the endTime of an event changing when I change the startTime using the startTimeField.

I have tried adding a change listener to the startTimeField, but I'm having trouble preventing the change to the endTime when the startTime increases or decreases.

Is there a feature for this? Or does anyone know the correct listener so that the endTime (and endDate, since when the endTime passes 00:00 the endDate also goes up 1 day) stay the same?

Thank you!


Post by marcio »

Hey lxxrxns,

The default behavior of Scheduler is to maintain the duration of an event, it means that for example, if an event has a duration of four days when you change the start date, it'll count as four days from there.

If you want to maintain the same endTime/endDate, you'll need to change the duration of the event.

Best regards,
Márcio


Post by lxxrxns »

Hi marcio,

Due to a different bug in Scheduler ( viewtopic.php?t=21622 ) that is currently not yet fixed, I made my scheduler so that every event has an end time of 23:59:00. This way, events will always overlap and therefore pack correctly.

However, as you can imagine, this results in a problem when changing the start time of an event (because then the end time passes onto the next day, and the end date changes...).

Would it be at all possible to prevent the end date and end time changing automatically when I change the start time? (i.e. disable keeping the duration the same?)


Post by alex.l »

Are we talking about SchedulerPro?

It is possible to do when you edit event record. You need to pass false as second param

eventRecord.setStartDate(newDate, false);

https://bryntum.com/products/scheduler/docs/api/Scheduler/model/TimeSpan#function-setStartDate

Regarding to default EventEditor, there no such setting. This logic is on EventModel level and not in StartDateField code. You could try to subscribe on https://bryntum.com/products/scheduler/docs/api/Scheduler/feature/EventEdit#event-beforeEventSave an change values before save.

All the best,
Alex


Post Reply