Save at once method not respecting client side hierarchy

Hi ,I’ve been using the Gantt chart and it is amazing what I have done so far and looking through the documentation I believe I shall do many things. It is a great tool. Congratulations.

But I’m stuck in a situation that I’m going to try to explain with some print screens below.

First using Data Processor synchronously It works perfectly! But it isn’t the ideal scenario for me.

Let’s suppose a schedule with lots of linked tasks. Like 1000 tasks. To work synchronously it is not an option due a cascade update that could be triggered with a simple drag and drop at the first task.

So I start to test using dataProcessor.setUpdateMode (“off”). Here is where the problems started for me.

Here I got an example of some tasks only at the client side…
image ![4|690x265]

When I hit the button “update” to trigger the function ‘dataProcessor.sendData()’ to send the data to the server I get the results below:

Please observe that “Task2” is in bold and apparently no set to the server and it returns on the same level of Task1 and that is wrong because Task2 is a child task of Task1.

Then, when I noticed that some records were in “bold” I saved the schedule again and end-up with this result.

As you can see for some reason the Gantt component did not respect the hierarchy.

I have also noticed that, sometimes, when I create child tasks and send the data to the server, the records don’t even obey the creation order. On this example below I just saved once again and reload the screen and return something completely different from the client-side.

I believe this happens because when we work only with the client side, we don’t have the ‘parent task id’ to keep the records in order. So, I would like to know how can I send the data to server side at once respecting the hierarchy created on the client-side.

I do hope I have made myself clear enough about my situation here.


Hi @Pedro_Lima,

Basically, for now, there is no good option to send all updates at once. It stays in our feature tracker and will be implemented in the future, unfortunately, there is no ETA.

Regarding fixing your current issue. You can fix it by updating the server-side logic with the following steps:

  1. collect all updates which will be sent to the server, here is the example of how it could be implemented:

  2. Loop through all collected task and add the new field to them:
    task.level = gantt.calculateTaskLevel

  3. Send this list of tasks to the server

  4. Sort them based on level

  5. Insert tasks with the highest level to the database, and collect their id changes: (chengedIds[oldId] = newId) .

  6. Do the same for the next level of tasks(there will be children of the previously inserted tasks), but before inserting, check it’s parent. If it’s parent’s id is changed(you can check it by the object created in the previous step), change the id of parent to the new one. Save the change of id to the child the same way as for parents.

  7. Do the same steps till all levels of tasks will be inserted to the database with the right order and correct parents

  8. Do the similar steps for the links - check their source and target , and if we changed they’re before, replace them with updated ones:

link.source = changedIds[link.source]

and add all links to the database.

After this request is completed, you can call gantt.cliarAll() and gantt.load() to get the data with correct ids and levels .
Or you can return the correct data in response and update it on the client-side.