Task Save Order


#1

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.


#2

Hi,
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


#3

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!


#4

Hi,
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.init(gantt);
dp.setTransactionMode("POST", true);

https://docs.dhtmlx.com/gantt/desktop__server_side.html#technique

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:

https://docs.dhtmlx.com/gantt/desktop__server_side.html#customrouting

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){
   pendingUpdates.push(action);
   
   clearTimeout(timer);
   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:

http://snippet.dhtmlx.com/169ed3b64


#5

Tks, I’m using the first solution.