[data grid] Column Width Persistence Fails During Data Updates and Auto-Sizing #14330
Labels
bug 🐛
Something doesn't work
component: data grid
This is the name of the generic UI component, not the React module!
duplicate
This issue or pull request already exists
feature: Column resize
support: commercial
Support request from paid users
support: pro standard
Support request from a Pro standard plan user. https://mui.com/legal/technical-support-sla/
The problem in depth
Long Story Short: 🤝
I'm encountering an issue with MUI's DataGridPro where the column widths do not persist as expected when the grid's data is updated or when auto-sizing is applied via useEffect. Specifically, I'm trying to maintain user-resized column widths across data updates and page reloads, but the columns revert to their default sizes after new data is fetched.
Steps to Reproduce: 🪜
Implement a DataGridPro with columns that allow resizing.
Store the column widths in localStorage when resized by the user.
Use useEffect to auto-size columns based on the initial data load.
Fetch new data every 15 seconds, updating the grid's rows prop.
Observe that the column widths reset after each data update, ignoring the persisted values from localStorage.
Expected Behavior:
The column widths should remain consistent, reflecting user adjustments even after data updates or page reloads.
Actual Behavior: 😬
Column widths reset to their default values after data updates or when the component re-renders, disregarding the values stored in localStorage.
Code Instance:
Environment: 🪄
@mui/x-data-grid-pro: ^6.0.0
React: 18.2.0
Browser: Chrome 116
It looks like a common issue 🤷 😁
I believe this issue is similar to what's described in #4310, where column resizing and persistence aren't working as expected across data updates. Any guidance or fixes would be appreciated, as this is critical for maintaining a consistent user experience.
Thanks in advance! :)
Your environment
`npx @mui/envinfo`
Search keywords: data grif, rendering layout, persistence column width
Order ID: 74059
The text was updated successfully, but these errors were encountered: