Hello Karanveer,
Gantt doesn’t have a built-in feature to copy and paste tasks. But you can use the Gantt API and implement a custom solution.
What can I use to copy & paste the whole of task data or selective task data?
You can use the copy
method that creates a deep copy of the provided object:
https://docs.dhtmlx.com/gantt/api__gantt_copy.html
To iterate the selected tasks, you can use the eachSelectedTask
method:
https://docs.dhtmlx.com/gantt/api__gantt_eachselectedtask.html
To iterate all tasks, you can use the eachTask
method:
https://docs.dhtmlx.com/gantt/api__gantt_eachtask.html
To add a new task, you can use the addTask
method and specify the task
object:
https://docs.dhtmlx.com/gantt/api__gantt_addtask.html
However, you need to make sure that the new task doesn’t have the same value in the id
parameter. Otherwise, it will replace the existing task.
Here is an example that can help you to start implementing your solution:
https://snippet.dhtmlx.com/kck3pnmh?text=gantt.%2Bcopy
Also, if you want to save all data from Gantt, you can use the serialize
method:
https://docs.dhtmlx.com/gantt/api__gantt_serialize.html
Would it be possible to copy & paste within different tabs?
If you have several Gantts on different tabs, and you want to transfer some tasks between them, it means, you need to save the data you copy from Gantt1 before you can paste it in Gantt2. The object where the data is saved should be available for both Gantts.
Is it possible to copy from external resource to gantt?
It should be possible to do that. But Gantt expects the task
object with the specific properties:
https://docs.dhtmlx.com/gantt/desktop__task_properties.html
This means before you add the data to Gantt, you need to make sure that the dataset has the properties and structure Gantt expects:
https://docs.dhtmlx.com/gantt/desktop__loading.html