Premium support for our pure JavaScript UI components


Post by dmitrypromx »

Hello,

I have a question about validating a drag drop operation:
Is it somehow possible to prevent dragging a task based on the date condition? For instance, I would like to block dragging the tasks into the past dates.
I've tried out the examples from this documentation:
https://bryntum.com/products/gantt/docs/api/Gantt/feature/TaskDrag#validating-a-drag-drop-operation. But it allows users to drag and drop the tasks into the past dates and then the app moves the tasks to the initial place.


Post by marcio »

Hey dmitrypromx,

Thanks for reaching out.

So, if I understood correctly, the validation is working correctly, but you're looking not to have the animation dropping back to its initial place?

Best regards,
Márcio


Post by dmitrypromx »

Hello Marcio,

Yes, I would like to know if it is somehow possible to stop dragging animation of a task based on the date condition. I mean before a user releases the mouse button. For instance, the following use case: a user can drag the task to the right (future dates) but can't drag it to the left (past dates).


Post by mats »


Post by dmitrypromx »

mats wrote: Tue Jul 23, 2024 6:08 pm

Something like what you see here? https://bryntum.com/products/schedulerpro/examples/highlight-time-spans/

Yes, exactly. Is it possible to implement similar behavior for the Gantt tasks?


Post by mats »


Post by dmitrypromx »

mats wrote: Tue Jul 23, 2024 7:05 pm

Yep, I think just about exactly the same code :)

https://bryntum.com/products/gantt/docs/api/Gantt/view/GanttBase#config-getDateConstraints

Yes, it works. Thank you!


Post by dmitrypromx »

Hello,

Is it somehow possible to set the start and end dates constraints separately for start date of the task and end date of the task?
For instance, we have a task from November, 1 to November, 20. And we want to prevent shrinking or moving this task before November, 10. I think we could set the end date constraint just for the end date in this case.


Post by alex.l »

Hi,

Please check docs https://bryntum.com/products/gantt/docs/api/Gantt/view/GanttBase#config-getDateConstraints

Returns
DateConstraint:
Constraining object containing start and end constraints. Omitting either will mean that end is not constrained. So you can prevent a resize or move from moving before a certain time while not constraining the end date.

All the best,
Alex


Post by dmitrypromx »

Hi Alex,
I've checed the docs but didn't find an answer on my question there. Could you please tell me what values we should specify in this constraint object in our case? What should be in the "start" and "end" dates properties?


Post Reply