import { ColDef , ColGroupDef , ColSpanParams , GridOptions } from '@ag-grid-community/core' ; var colSpan = function ( params ) { return params . data === 2 ? 3 : 1 ; } ; const columnDefs = [ { headerName : 'A' , field : 'author' , width : 300 , colSpan : colSpan , } , { headerName : 'Flexed Columns' , children : [ { headerName : 'B' , minWidth : 200 , maxWidth : 350 , flex : 2 , } , { headerName : 'C' , flex : 1 , } , ] , } , ] ; function fillAllCellsWithWidthMeasurement ( ) { Array . prototype . slice . call ( document . querySelectorAll ( '.ag-cell' ) ) . forEach ( function ( cell ) { var width = cell . offsetWidth ; var isFullWidthRow = cell . parentElement . childNodes . length === 1 ; cell . textContent = ( isFullWidthRow ? 'Total width: ' : '' ) + width + 'px' ; } ) ; } const gridOptions = { defaultColDef : { resizable : true , } , columnDefs : columnDefs , rowData : [ 1 , 2 ] , onGridReady : function ( ) { setInterval ( fillAllCellsWithWidthMeasurement , 50 ) ; } , } ; document . addEventListener ( 'DOMContentLoaded' , function ( ) { var gridDiv = document . querySelector ( '#myGrid' ) ; new agGrid . Grid ( gridDiv , gridOptions ) ; } ) ;