Hi,
How can I set parent on a task properly with validation programmatically?
I am using gantt-4.3.2
I tried the following, and it works and are triggering UI to redraw fine. But there are no validation to check if this is an illegal parent:
(You can replicate this by running the code in the advanced example)
gantt.taskStore.getById(15)["parentId"] = 12
I would expect e.g. a "setParent" function that validates the input, but that does not exists:
gantt.taskStore.getById(15).setParent(12)
Ok that is perfect! But I found 1 more issue when setting parent to null:
gantt.taskStore.getById(15)["parentId"] = null;
There are already functions for setting start/end date, duration etc (see attachment), so maybe there should be a setParent or setParentId function anyway?
- Attachments
-
- Screenshot 2022-01-21 124750.png (31.53 KiB) Viewed 185 times
There are methods like
https://bryntum.com/docs/gantt/api/Core/data/mixin/TreeNode#function-appendChild
https://bryntum.com/docs/gantt/api/Core/data/mixin/TreeNode#function-clearChildren
https://bryntum.com/docs/gantt/api/Core/data/mixin/TreeNode#function-removeChild
To add a task to root, you can use gantt.taskStore.rootNode.appendChild(task)
.
All the best,
Alex