Size Columns to Fit the Viewport
A method scales column widths proportionally so the total width exactly fills the grid viewport, with no horizontal scrollbar. This suits small tables that should never scroll sideways.
Planned. This page shows the specification from issue #185. The live example, source for every framework and the API reference replace it when the feature ships.
Live example
A grid with 5 columns inside a resizable container that the user can drag-resize.
Expected behavior
After fitting, the sum of column widths equals the viewport width and no horizontal scrollbar appears. Columns with suppressFit keep their width while the others absorb the difference. When auto-fit is on, resizing the container refits the columns after a debounce.
Planned API surface
api.fitColumns(options?)gridOptions.fitColumnsOnResizeoptions.respectMinMaxcolumnDef.suppressFitevent:columnResizedAcceptance criteria
- The total column width equals the viewport width minus the vertical scrollbar width, within 1px. (pending)
- Columns with suppressFit keep their widths unchanged. (pending)
- If minWidth constraints prevent fitting, a horizontal scrollbar appears and no column goes below its minWidth. (pending)
- Auto-fit runs at most once per animation frame while the container resizes. (pending)