import { GridOptions , KeyCreatorParams , ValueGetterParams } from '@ag-grid-community/core' ; const gridOptions = { columnDefs : [ { field : 'athlete' , minWidth : 200 } , { field : 'gold' } , { field : 'silver' } , { field : 'bronze' } , { field : 'total' } , { field : 'age' } , { field : 'country' , rowGroup : true , hide : true , valueGetter : countryValueGetter , keyCreator : countryKeyCreator , } , { field : 'year' } , { field : 'date' } , { field : 'sport' , minWidth : 200 } , ] , defaultColDef : { flex : 1 , minWidth : 150 , resizable : true , } , autoGroupColumnDef : { minWidth : 200 , } , } ; function countryKeyCreator ( params ) { var countryObject = params . value ; return countryObject . name ; } function countryValueGetter ( params ) { var countryName = params . data . country ; var countryCode = countryName . substring ( 0 , 2 ) . toUpperCase ( ) ; return { name : countryName , code : countryCode , } ; } 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 ) ) ; } ) ;