When gantt.clearAll() is called only client side is cleared. How to update database data?


#1

Hi,
If I call gantt.clearAll(); on the client side all tasks and links are removed. But how I can remove also from database? I’m using gantDataprocessor and JSONGanttConnector.
If after clearAll() I call explicitly dp.sendData(); (where dp is gantt.dataProcessor) nothing happens!
Thanks


#2

Hello,
You can use gantt.eachTask function and delete all tasks with gantt.deleteTask command:

gantt.eachTask(function(task){
  if(gantt.isTaskExists(task.id))
    gantt.deleteTask(task.id);
});

To do that with one request, you can use batchUpdate function:

gantt.batchUpdate(function () {
  gantt.eachTask(function(task){
    if(gantt.isTaskExists(task.id))
      gantt.deleteTask(task.id);
  });
});

You can learn more about the functions and methods in the following articles:
https://docs.dhtmlx.com/gantt/api__gantt_eachtask.html
https://docs.dhtmlx.com/gantt/api__gantt_deletetask.html
https://docs.dhtmlx.com/gantt/api__gantt_istaskexists.html
https://docs.dhtmlx.com/gantt/api__gantt_batchupdate.html