-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[DataGrid] Add methods to save and restore scroll position #5071
Comments
Could you provide a reproduction demonstrating the error you see? With static rows it works, but with rows loaded from the server it didn't, but no error. We do can allow to save the scroll position and restore it passing the value in the |
The issue you mentioned has the exact same error that we're experiencing but I can try to get you a quick reproducible example. We're just calling apiRef.current.scroll inside an useEffect (which has apiRef.current as a dependency) so it should be easily reproducible on a codesandbox. Tomorrow we'll post something! |
There you go - https://codesandbox.io/s/compassionate-kirch-bpxoz1?file=/src/App.tsx @m4theushw Is there something wrong in our usage? I'd assume that waiting for |
@AndreSilva1993 your usage is correct for any React component, but the DataGrid doesn't work with it. When the effect runs it only means that |
@m4theushw Then how would you suggest for us to deal with us? I feel like waiting for windowRef is a bit hack-ish as it's an internal implementation. |
I don't see this anywhere in the |
Hey guys, is there any update on that? Any method to store and restore the last scrolled position on datagrid? |
any workaround ? |
Duplicates
Latest version
Summary 💡
There already is an API to export/restore parts of the Datagrid state (related to #820). It would be awesome to extend this and add scroll position. As a current workaround we hook into
rowScroll
event to persist scroll position but restoring it is a bit hacky:Without the
setTimeout
hack we getExamples 🌈
No response
Motivation 🔦
We want to be able to restore Datagrid scroll position. Ideally by using
initialState
prop.Maybe there's a workaround until then that's cleaner as the hack suggested above.
Order ID 💳 (optional)
41693
The text was updated successfully, but these errors were encountered: