Auto Size all columns to fit content

Grid Resizing:
https://www.ag-grid.com/javascript-grid-resizing/

sizeColumnsToFit – this tries to squeeze all the columns in the view – no horizontal scrolling

autoSizeAllColumns – this tries to size all columns to to fit the data – horizontal scrolling

// If you need to resize specific columns 
var allColIds = params.columnApi.getAllColumns()
    .map(column => column.colId);
params.columnApi.autoSizeColumns(allColIds);

// If you want to resize all columns
params.columnApi.autoSizeAllColumns();

Leave a Comment

tech