When I call
gantt.clearAll();
gantt.load(xxx);
The gantt always scrolls back to the start of the gantt.
How can I
a) Prevent this
b) auto scroll the gantt back to its old position
Thanks
When I call
gantt.clearAll();
gantt.load(xxx);
The gantt always scrolls back to the start of the gantt.
How can I
a) Prevent this
b) auto scroll the gantt back to its old position
Thanks
Hi,
If you call clearAll() without reloading data, you can understand. The method clears all tasks and scrollbar disappears also.
To scroll gantt to its old position - if you reload the same data, try showTask(). If no - you can scrolls the Gantt container to the specific position by scrollTo().
Awesome that did the trick
private saveScrollState(timelineComponent: TimelineComponent){
var sPos = gantt.getScrollState();
timelineComponent.scrollPosX = sPos.x;
timelineComponent.scrollPosY = sPos.y;
}
private restoreScrollState(timelineComponent: TimelineComponent){
let x = timelineComponent.scrollPosX;
let y = timelineComponent.scrollPosY;
gantt.scrollTo(x,y);
}
may I ask when you call restoreScrollState
?
I cannot find a suitable event like onParse
, onGanttReady
for example that is actually fired when there can be scrolled.
Also, the onScroll
event is fired so many times before and AFTER the above events are fired, it tends to overwrite any existing values to 0 even before I get a chance to restore the scroll…
Just before you call gantt.render() call restoreScrollState()