Adding thousands of tasks after initialization

After the gantt and all the tasks have been rendered, I allow the user to copy and paste a project with all of this sub tasks. However, there are situations where there are thousands of sub tasks being added. Is there a better way to add these tasks to an already rendered gantt chart than gantt.AddTask()? Can I add them all at once?

I could be wrong, but I think you can use gantt.parse to load in data in “batch”.

Thanks, I’ve already done that but it requires re initializing gantt tasks. That loses the position, as well as the open tasks in the gantt.

I’ve already tried


But I don’t want to clear it all.

Again, I may be wrong but I remember that you don’t have to clear before calling parse to add data. Maybe the staff here can give you more info. I’m interested in knowing too.

If you add a thousand tasks at the same time, Gantt repaints the chart a thousand times. To do it only once, you can use the batchUpdate method:

Here is an example of how it works:

However, Gantt is a client-side tool. So, if you add tasks on the client-side, Gantt will send a thousand requests to the server. Some tasks might be lost because of connectivity issues, and it is not related to Gantt. There is only one way to send all tasks in one request, and it is the POST transaction mode:

It is better to create tasks on the server-side and load them later via parse or load methods.

To keep the position after loading the data, you can disable the initial_scroll property:
In previous versions, Gantt closed open tasks after loading the data, but that bug was fixed in the 6.2.4 version:
The following snippet demonstrates how it works:

Thanks, that helped me out.