-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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 position sticky to DataGrid columns (header) on scroll down #5189
Comments
It seems to be possible as follow, but not recomended export const StyledDataGrid = styled(DataGrid)(({ theme }) => ({
"& .MuiDataGrid-main": {
// remove overflow hidden overwise sticky does not work
overflow: "unset"
},
"& .MuiDataGrid-columnHeaders": {
position: "sticky"
},
"& .MuiDataGrid-virtualScroller": {
// remove the space left for the header
marginTop: "0!important"
}
})); https://codesandbox.io/s/datagriddemo-demo-mui-x-forked-6izdkg?file=/demo.tsx |
Thanks for you reply! @alexfauquette https://codesandbox.io/s/persistentdrawerleft-demo-material-ui-forked-s1g7sq?file=/demo.tsx What is causing that ? I tried to fix but had no luck.. |
I put a fix width to the data grid container and it works find, so it must be a CSS problem. I will not have time to have a deeper look into it. For generic question, you may find help on StackOverflow which has a much larger community |
using custom css, it break at v6.. |
This was also asked in #7588 (comment) I'll add this demo to our column headers docs. |
@cherniavskii think we can close this? Seems like a duplicate of #15466 if I am understanding correctly. |
Duplicate of #15466 |
Duplicates
Latest version
Current behavior 😯
No response
Expected behavior 🤔
I would like to achieve a sticky position for the DataGrid Columns header when scrolling down the page. Basically, all I want is when i scroll down and the table still has content is to see the columns header stuck on the top of the page, so I know what are the headers of each columns are. And for the sticky header to be gone when i scroll down and passed all the table content.
Steps to reproduce 🕹
I have tried the following but did not work :
https://codesandbox.io/s/datagriddemo-demo-mui-x-forked-0hq08f?file=/demo.tsx
Context 🔦
No response
Your environment 🌎
`npx @mui/envinfo`
Order ID 💳 (optional)
No response
The text was updated successfully, but these errors were encountered: