import { FirstDataRenderedEvent , GridOptions , IDetailCellRendererParams } from '@ag-grid-community/core' ; const gridOptions = { columnDefs : [ { field : 'name' , cellRenderer : 'agGroupCellRenderer' } , { field : 'account' } , { field : 'calls' } , { field : 'minutes' , valueFormatter : "x.toLocaleString() + 'm'" } , ] , masterDetail : true , detailRowHeight : 200 , detailCellRendererParams : { detailGridOptions : { columnDefs : [ { field : 'callId' } , { field : 'direction' } , { field : 'number' , minWidth : 150 } , { field : 'duration' , valueFormatter : "x.toLocaleString() + 's'" } , { field : 'switchCode' , minWidth : 150 } , ] , defaultColDef : { flex : 1 , editable : true , resizable : true , } , } , getDetailRowData : function ( params ) { params . successCallback ( params . data . callRecords ) ; } , } as IDetailCellRendererParams , getRowNodeId : function ( data ) { return data . account ; } , defaultColDef : { flex : 1 , editable : true , resizable : true , } , onFirstDataRendered : onFirstDataRendered , } ; function onFirstDataRendered ( params ) { setTimeout ( function ( ) { params . api . forEachNode ( function ( node ) { node . setExpanded ( true ) ; } ) ; } , 0 ) ; } function flashMilaSmithOnly ( ) { var detailGrid = gridOptions . api ! . getDetailGridInfo ( 'detail_177001' ) ; if ( detailGrid ) { detailGrid . api ! . flashCells ( ) ; } } function flashAll ( ) { gridOptions . api ! . forEachDetailGridInfo ( function ( detailGridApi ) { detailGridApi . api ! . flashCells ( ) ; } ) ; } document . addEventListener ( 'DOMContentLoaded' , function ( ) { var gridDiv = document . querySelector ( '#myGrid' ) ; new agGrid . Grid ( gridDiv , gridOptions ) ; fetch ( 'https://www.ag-grid.com/example-assets/master-detail-data.json' ) . then ( response => response . json ( ) ) . then ( function ( data ) { gridOptions . api ! . setRowData ( data ) ; } ) ; } ) ;