Using updateData in flat view changes scroll

Answered
Accobat Development 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

5 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
Accobat Development 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

Public
Tigran February 21, 2023

Hello

I tried the functionality you mentioned above.
It works properly only if the user is in the middle of the report table.
For example if user removes very last column, then the scroller appears a little away than the last column․
But I noticed that this happens if there are more than 38 columns.

Attachments:
1.png
2.png
code.png

Solomiia Andrusiv created a new ticket #52993 from this answer
Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster February 21, 2023

Hello, Tigran!
 
Thank you for contacting us.
 
We have moved your question to a separate thread and provided an answer there: https://www.flexmonster.com/question/how-to-remain-scroll-at-the-right-end-after-removing-the-last-column-on-flat-table.
 
Regards,
Solomiia

Please login or Register to Submit Answer