View as Markdown

API reference: @salmonui/data-grid/engine

fitColumnWidthsfunction

import { fitColumnWidths } from '@salmonui/data-grid/engine';
function fitColumnWidths(columns: readonly FitColumn[], target: number): number[] | null;

Expands column widths proportionally so that their sum reaches target. Columns are never shrunk: when the widths already reach target the input widths are returned unchanged and the grid scrolls horizontally. Flexible columns grow in proportion to their width, capped at max; the result is whole px and sums to target unless every flexible column is capped. Returns null when nothing changes.