Could you provide a syncItems method to data consistency?

Hi there, I think gantt should provide a method, for example : syncItems, that way, could reload data, without break the current items status (for example, open state), but keep the status, only sync the item name plan dates etc, and also added items or delete items from remote.

for example, I added the method below trying to simulate this method:

I think gantt should support this officially.

Hello Kevin,
We have a bug in the tracker regarding saving the open state. It will be fixed in the future. I cannot give you an ETA, but I will notify you when the fix is ready.
Now, as a workaround, you can save the IDs of open tasks before parsing the data, then open those tasks:
https://snippet.dhtmlx.com/374b09cb2

Please, tell me if it doesn’t work for other properties.

If a task already exists, Gantt updates the parameters of that task. In the following snippet, you can see that initially, “Task #2” has custom_property. After you parse the data, the name changes, and there is no custom_property anymore:
http://snippet.dhtmlx.com/c28687f3c

If you have the data that don’t have some tasks that you have in the chart, Gantt won’t delete those tasks after you load the data. And it is expected behavior because it is a function of loading the data, not of reloading the data and not of deleting the data. It allows loading one task without deleting all existing tasks. If you need to remove the tasks, you can use gantt.clearAll() before loading the data:
https://docs.dhtmlx.com/gantt/api__gantt_clearall.html

1 Like

Thanks Ramil, your solution worth trying, I will try this later ,thanks

Hello Kevin,
The dev team fixed the bug with the open property. Now, if you parse the data and some tasks already exist, they won’t be collapsed:
https://snippet.dhtmlx.com/d83762aa0

1 Like