Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

With AgGrid React, Is there a way to preserve column widths across React rerenders?

I'm seeing unexpected column width changes when rerendering a React component that contains an AgGrid.

Repro:

  1. Render an AgGrid with React
  2. Drag a column to change its width
  3. Rerender the AgGrid with new data

Expected:

  • Column retains its width

Actual:

  • Column snaps back to its original width.

Is there a way to get columns to retain their width, kind of like suppressScrollOnNewData, but for maintaining column width?

like image 550
vilterp Avatar asked Dec 05 '25 13:12

vilterp


1 Answers

I was having a similar issue. The solution was to not use flex in any column definition. In my case I had flex: 1 in the defaultColDef.

Got it from this answer: https://stackoverflow.com/a/70654209

like image 60
alainbex Avatar answered Dec 08 '25 07:12

alainbex



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!