Need a special offer?Find out if your project fits.
+

How to remain scroll at the right end after removing the last column on flat table

Answered
Tigran asked on 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.

Solomiia Andrusiv created this ticket from #52953

6 answers

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster February 21, 2023

Hello, Tigran!
 
Kindly note that by design, Flexmonster scrolls to the far left end of the grid every time the field is removed. This behavior can be overridden by using Flexmonster beforegriddraw, aftergriddraw, reportcomplete and reportchange events along with scrollTo() API call as follows:

let handler = () => {
    scrollPane = document.querySelector("#fm-pivot-view div.fm-data-sheet > div.fm-scroll-pane")
    x = scrollPane.scrollLeft;
    y = scrollPane.scrollTop;
};

pivot.on("reportcomplete", () => {
    pivot.on("beforegriddraw", handler)

    pivot.on('reportchange', () => {
      pivot.off('reportchange');
      pivot.off('beforegriddraw', handler);

      pivot.on('aftergriddraw', () => {
        pivot.off('aftergriddraw');

        setTimeout(() => {
          scrollPane.scrollTo(x, y);
        }, 0);

      });
    })
});

We have prepared the JSFiddle example for reference: https://jsfiddle.net/flexmonster/r5b4eq2L/.
 
Hope it helps.
Feel free to contact us in case of any other questions.
 
Regards,
Solomiia

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster February 28, 2023

Hello, Tigran!

Hope you are doing well.

Our team is wondering if you had a chance to test the suggested approach. Could you please let us know if it was helpful?

Looking forward to hearing from you.

Regards,
Solomiia

Public
Tigran March 2, 2023

Hi, Solomiaa!

First I mentioned that this happens when the columns are greater than 38.
But this is not the case.
This happens when X is greater than 5000 or more.

Public
Solomiia Andrusiv Solomiia Andrusiv Flexmonster March 3, 2023

Hello, Tigran!
 
Thank you for getting back to us.
 
Kindly note that the suggested approach can't control the scroll with 100% accuracy as we don't save and restore the pixels, only the scroll position. 
It is possible to adjust the approach more by catching the last column removed and scrolling to the far right end in this case. For that, you need to compare the fields in the report before and after the reportchange. The fields can be retrieved by using the getReport() API call.
 
Hope it helps.
Feel free to contact us in case of any other questions.
 
Kind regards,
Solomiia

Public
Tigran March 6, 2023

Thanks for your halp.

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster March 6, 2023

Hello,

Thank you for the feedback.

As always, feel free to contact us if other questions arise. 

Kind regards,
Nadia

Please login or Register to Submit Answer