Get Free Trial

Using updateData in flat view changes scroll

Answered
Jimmy asked on September 1, 2021

Hello,
 
When having a vertical scrollbar in the grin and scrolling all the way to the right.
If you then call “updateData”  using with “partial: true” this resets the scroll to the left side: https://jsfiddle.net/njkbd5s9/
 
/Jimmy

3 answers

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 1, 2021

Hello, Jimmy,
 
Thank you for reaching out to us.
 
We suggest executing the following code snippet before actual data update to restore scroll position:

const scrollPane = document.querySelector(".fm-data-sheet > div");
const initialPosition = {
x: scrollPane.scrollLeft,
y: scrollPane.scrollTop
}
pivot.on("aftergriddraw", () => {
pivot.off("aftergriddraw");
setTimeout(() => {
scrollPane.scrollTo(initialPosition.x, initialPosition.y);
}, 0);
});

 
It allows saving scroll position before the data was updated and restore it after the render is complete.
Here is JSFiddle demonstrating this approach: https://jsfiddle.net/flexmonster/10jpvfco/.
 
Please let us know if it helps.
 
Kind regards,
Illia

Public
Jimmy September 1, 2021

Hello Illia,
 
Thanks this works for the vertical scroll.
But using it with the horizontal scroll it doesn’t scroll all the way: horizontal
 
/Jimmy
 

Attachments:
after.PNG
before.PNG

Public
Illia Yatsyshyn Illia Yatsyshyn Flexmonster September 2, 2021

Hello,
 
Thank you for your feedback.
 
Please note that this is only the workaround that may produce slight differences in a horizontal scroll on the flat form. This is due to possible differences in columns’ width after the data update.
 
Currently, there are no other workarounds for this case.
 
Please contact us if other questions arise.
 
Kind regards,
Illia

Please login or Register to Submit Answer