import { ColDef , GridOptions , RowGroupOpenedEvent } from '@ag-grid-community/core' ; const columnDefs = [ { field : 'athlete' , width : 150 , rowGroupIndex : 0 } , { field : 'age' , width : 90 , rowGroupIndex : 1 } , { field : 'country' , width : 120 , rowGroupIndex : 2 } , { field : 'year' , width : 90 } , { field : 'date' , width : 110 , rowGroupIndex : 2 } , ] ; const gridOptions = { columnDefs : columnDefs , rowData : null , animateRows : false , groupDisplayType : 'groupRows' , onRowGroupOpened : onRowGroupOpened , defaultColDef : { editable : true , sortable : true , resizable : true , filter : true , flex : 1 , minWidth : 100 , } , } ; function onRowGroupOpened ( event ) { var rowNodeIndex = event . node . rowIndex ! ; var childCount = event . node . childrenAfterSort ? event . node . childrenAfterSort . length : 0 ; var newIndex = rowNodeIndex + childCount ; gridOptions . api ! . ensureIndexVisible ( newIndex ) ; } document . addEventListener ( 'DOMContentLoaded' , function ( ) { var gridDiv = document . querySelector ( '#myGrid' ) ; new agGrid . Grid ( gridDiv , gridOptions ) ; fetch ( 'https://www.ag-grid.com/example-assets/olympic-winners.json' ) . then ( response => response . json ( ) ) . then ( data => gridOptions . api ! . setRowData ( data ) ) ; } ) ;