Task Save Order


Hi guys,

If you are using REST mode, and need to save / update tasks 1 by 1 -

Is there a particular order that each task saves if you send multiple to be updated? I wonder this because sometimes my server side fails, after updating 50+ tasks to a later end date. But it appears that it saved the tasks from the bottom of the gantt chart to the top of the gantt chart. Is this true?

If it’s true: is it possible to save the tasks in order of first task on the gantt chart (earliest start date) to the bottom (latest start date) so that if the server side does fail somewhere in the middle. The auto-scheduling will take care of the tasks that follow? In our projects all tasks are linked, so if this happened it seems like it would help to have it in the other order.


Tasks should be updated in topological order (en.wikipedia.org/wiki/Topological_sorting) - predecessors go first, successors after them. From I can see from sources onAfterTaskUpdate (thus the server update) is called in the same order.

There is a way to change the order in which server updates are sent for auto scheduling, although it is more a hack than a proper solution:
docs.dhtmlx.com/gantt/api__gant … event.html
onAfterAutoSchedule receives an array of updated tasks - this array is passed by reference, changing the order of elements there will change the order in which updates are sent.

As a more permanent solution, we probably need some kind of batch api requests instead of updating items one by one. This is currently not supported, but we’ll look into possible updates of dataProcessor


There are no bach-request?

If I have a gantt with 500 tasks ans links, with autoschedule, and I move the first task for example, the gantt will make 500 different requests to the server???

This answer is very important to me buy the gantt!


unfortunately, we still don’t have a good solution.
There are a couple of options, though.

  1. You can initialize the dataProcessor in ‘POST’ mode,
var dp = new gantt.dataProcessor("apiUrl");
dp.setTransactionMode("POST", true);


It will send multiple updates per request, but the request format itself will be a bit more difficult to work with,
https://docs.dhtmlx.com/dataprocessor__basic_principles.html#commonrequestparametersformat - pls see the example in 2) several records in one request paragraph.

  1. Alternatively, you can define your own handler for the updates:


In there you can use something like setTimeout in order to buffer updates and send them all at once manually:

var timer;
var pendingUpdates = [];
function delayedCall(action){
   timer = setTimeout(function(){
    gantt.alert("<h2>you can send these updates to the backend manually</h2>" +
     "<pre>"+ JSON.stringify(pendingUpdates, null, 2) + "</pre>");
      pendingUpdates = [];
   }, 100);

gantt.createDataProcessor(function(entity, action, data, id){
    return delayedCall({
     	entity: entity,
        action: action,
        id: id,
        data: data

Here is a working snippet:



Tks, I’m using the first solution.