Hi,
I want to limit drag and drop of subtask to the parent task only. I'm using typescript, how I can handle this.
Thanks,
Bharat
Hi Bharat,
There is preventable https://bryntum.com/products/gantt/docs/api/Gantt/feature/TaskDrag#event-beforeTaskDrag event.
Just add check you need into handler and return true
/false
to allow/prevent action.
As example, check https://bryntum.com/products/gantt/docs/api/Core/data/mixin/TreeNode#property-isParent property of draggable record.
All the best,
Alex
Hi,
You could use https://bryntum.com/products/gantt/docs/api/Grid/feature/RowReorder#event-gridRowBeforeDropFinalize to achieve that
And here is the code I used to implement this
features : {
rowReorder : {
listeners : {
gridRowBeforeDropFinalize (event) {
const { context } = event;
const gantt = window.gantt;
const parent = gantt.project.taskStore.getById(context.oldPositionContext[0].parentId);
if (parent.name.toLowerCase() === 'setup web server' && context.insertBefore.parent?.name.toLowerCase() === 'website design') {
context.valid = false;
}
}
},
}
}