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”.

https://docs.dhtmlx.com/gantt/desktop__loading.html

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

      ...
      gantt.clearAll();
      gantt.parse(data);

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.

Hello,
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:
https://docs.dhtmlx.com/gantt/api__gantt_batchupdate.html

Here is an example of how it works:
http://snippet.dhtmlx.com/5/269997138

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:
https://docs.dhtmlx.com/api__dataprocessor_settransactionmode.html

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:
https://docs.dhtmlx.com/gantt/api__gantt_initial_scroll_config.html
In previous versions, Gantt closed open tasks after loading the data, but that bug was fixed in the 6.2.4 version:
https://docs.dhtmlx.com/gantt/whatsnew.html#624
The following snippet demonstrates how it works:
http://snippet.dhtmlx.com/5/0e7b42cae

Thanks, that helped me out.