How to preserve vertical scroll position after update

How to preserve vertical scroll position after update

seiser01seiser01 Posts: 17Questions: 9Answers: 0

I have implemented a table with a checkbox at the beginning of each row. The state of the checkbox controls whether the data in the corresponding row is included in a calculation. The table also allows for vertical scrolling. The problem is that if the table has been scrolled and you click on the checkbox, the resulting submit causes the table to scroll back to the top. Is there a way to prevent this from happening?

Before Clicking on the Checkbox

After Clicking on the checkbox

Answers

  • sandysandy Posts: 913Questions: 0Answers: 236

    Hi @seiser01 ,

    Could you please link to a test case or link to your page so that we can see the issue? Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Thanks,
    Sandy

  • seiser01seiser01 Posts: 17Questions: 9Answers: 0

    Unfortunately, I cannot create a link to a test case. The page is hosted on a fileserver that is behind a firewall and is not externally accessible.

    I simply want to store the scroll position of my datatable and then restore it after a submit. Will save State accomplish this for me?

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    I wonder why the table is scrolling after you click the checkbox? Maybe you can build a simple test case showing us what you are doing so we can offer suggestions. It doesn't need to replicate everything just needs to be enough so we can see your checkbox and your click event and of course the scrolling after the click event.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

This discussion has been closed.