Our pure JavaScript Scheduler component


Post by doonamis »

Hello!

How can I limit or reset the event startTime if the event has changed the resource?

What I mean is: If I start to drag the event but on the same resource you can edit the startTime with no problem, the thing is if I move from one resource to another I want to limit the drop to be on the same time

Thanks!

Post by saki »

There is Validation demo that demonstrates how to implement event Drag&Drop validations. The core is validatorFn that performs the validation itself.

Probably the easiest for you would be to use the same approach with validations you need for your application.

Post by doonamis »

Hello saki,

Sure, but how can I know if the event has changed resource? I've found than in context you have the newResource object, but is there something like oldResource or anything I can check to know if the resource is a different one?

Post by sergey.maltsev »

Hi!

There are newResource and draggedRecords within context in validatorFn.
So you could check previous resource for each dragged record.

This is online demo where you could check the source
https://www.bryntum.com/examples/scheduler/validation/

Please refer to this docs
https://www.bryntum.com/docs/scheduler/#Scheduler/feature/EventDrag#config-validatorFn

Post by doonamis »

Hello Sergey, thanks that worked!

Is there a way to obtain this difference only after the drag of the event ends? I tried the "eventDrop" listener but here the event already has the new resource id, I've seen theres already a beforeEventDropFinalize listener, could it work here?

The idea is every event has a transportTime variable and this depends on the previous event position, so if you change the resource of an event it needs to recalculate, currently I recalculate the transport times for the new resource on the eventDrop but I would also like to recalculate the events for the old resource

Thanks!

Post by saki »

Did you try to listen to beforeEventDropFinalize?

If context there does not contain the data you need but this data is available during drag then you could store it during drag and then retrieve id during beforeEventDropFinalize handler – not that neat so I hope it won't be necessary. Let us know please in this case, we'd add the missing piece to context.

Post Reply