I have a problem, I create some entity, after creation I do a fetch of my request so that new data comes. Since I work with react, the data is updated and the component is re-rendered. But after re-rendering my horizontal scroll moves to where the very first task begins, and I want to save the scroll
Hello Molven,
If you use the regular Gantt version and don’t remove the existing data before the load with the clearAll
method, parsing the new data shouldn’t reset the scroll position.
But if you use the clearAll
method, this is expected behavior. When you call that method, the tasks are removed from Gantt, so, its scroll position is set to 0 (because there are no tasks). So, you need to save the scroll position before calling the clearAll
method, then use the scrollTo
method after you load the data.
Here is an example of how it can be implemented:
If you use React Gantt, the scroll position may reset if Gantt is reinitialized under the hood. The approach is the same - save the scroll position and restore it after loading the data.
If it happens when you group tasks, this is a bug that was fixed in the 9.0.11 version:
https://docs.dhtmlx.com/gantt/whatsnew.html#:~:text=Fix%20the%20issue%20where%20scroll%20position%20reset%20on%20re-render%20when%20ReactGantt%20was%20in%20the%20groupBy%20mode
If that doesn’t help you, I need a snippet or a ready demo so that I can reproduce the issue locally.
Thanks a lot! This is what I need