How can i add or removed a task or sub task in Gantt chart without destroying the existing Gantt instance when Gantt chart is completely loaded.
Support Forum
Please study the https://bryntum.com/docs/gantt/api/Gantt/data/TaskStore class, it has add
and remove
methods. You can see the add method in use in the https://bryntum.com/examples/gantt/advanced/ (Create button)
store.add({ name : 'foo'})
To achieve that you need to use apendChild
method.
Please check docs : https://bryntum.com/docs/scheduler/api/Core/data/Model#function-appendChild
Here is an example of how you can use it:
gantt.taskStore.getById('11').appendChild({ name: 'foo' });
Best regards,
Tasnim
You can get the whatever taskRecord you want by the getById
function
Please check the docs here: https://bryntum.com/docs/scheduler/api/Core/data/Store#function-getById
I also gave an example in my last thread which is this:
gantt.taskStore.getById('11').appendChild({ name: 'foo' });
Best regards,
Tasnim
NO, I'm not asking this. My question is if i get a task index by this function (gantt.taskStore.indexOf(id)) it will return an index on which task is available on Gantt chart, so after that i want to push some other task on that index how can i do that ?
As you see that, I give an ID and it returns the index which i want to use for the next task to add on that index
Hi,
The TaskStore in Gantt is a tree store, inserting at a specific index only makes sense in a flat store. What you probably want to do is add to the parent of the task, adjacent to the task. Try something like this:
const task = gantt.taskStore.getById(...);
task.parent.insertChild(newTask, task);
Docs for insertChild here: https://bryntum.com/docs/gantt/api/Core/data/Model#function-insertChild
Johan Isaksson
I want to add a parent task or a sub-task on a specific index like insert at index n, for example, gantt is loaded and I want to add a new task at index 2 or Nth index.
Example:
Take the example of array [a , b , c , d , e] . I want to add a new letter "f" to this array at index 2 so the new array will be
[a , f , b , c , d , e]. The same experience i want in gantt chart.