Column Pinning on DataGrid not pinning to side when scrolling horizontally
hey guys, so im using datagrids and trying to work on the datagrid column pinning functionality, now ive followed the reui docs for the example of using datagrids
now in my implementation when i pin it to the left or right it works but when i scroll horizontally it doesnt stay pinned to the screen on the side
https://github.com/moahnaf11/MCA-Metronic/blob/main/src/pages/archived/archived.tsx
heres the file for the code lines 731 is the datagrid component
Replies (1)
Hi Mohammad,
Understanding
You're using the ReUI DataGrid with column pinning. When you pin columns to the left or right, the pinning works initially but the columns don't stay in place when you scroll horizontally.
Solution
This is a common issue with ReUI's DataGrid column pinning. The pinned columns use CSS position: sticky, which requires the table container to have overflow-x set to auto or scroll for the sticky behaviour to work.
Here's what to check:
-
Make sure the DataGrid is inside the ReUI
DataGridTableViewport— the wrapper component that handles the scrollable viewport with proper overflow. If you wrapped the DataGrid in your own container, the overflow might not be set correctly. -
Check for parent
overflow: hidden— if any ancestor of the DataGrid hasoverflow: hidden, sticky positioning on the columns won't work outside that container. Remove or changeoverflow: hiddenon parent divs. -
The DataGrid needs a defined width — if the grid is inside a flex container without a fixed width, the table may not have enough room to scroll, and sticky won't engage.
-
Verify you're passing
columnPinningstate correctly — In TanStack Table v9 (used by ReUI), pinning usesstart/end(notleft/right). Your pin state should look like:columnPinning: { start: ['columnId1', 'columnId2'], end: ['columnId3'] }
Could you share a minimal reproduction of your DataGrid setup? That would help narrow down exactly where the sticky positioning is being blocked.
Sources
Next Steps
If the above doesn't resolve it, try isolating the DataGrid in a simple page with no custom containers to confirm the pinning works in a clean setup.
This reply was generated by AI. A human will follow up if needed.