import { GridOptions } from '@ag-grid-community/core' ; const gridOptions = { columnDefs : [ { field : 'country' , rowGroup : true , hide : true } , { field : 'year' , rowGroup : true , hide : true } , { field : 'gold' , aggFunc : 'sum' } , { field : 'silver' , aggFunc : 'sum' } , { field : 'bronze' , aggFunc : 'sum' } , ] , defaultColDef : { flex : 1 , minWidth : 150 , sortable : true , resizable : true , } , autoGroupColumnDef : { minWidth : 300 , cellRendererParams : { innerRenderer : ( params ) => { if ( params . node . footer ) { const isRootLevel = params . node . level === - 1 ; if ( isRootLevel ) { return `<span style="color:navy; font-weight:bold">Grand Total</span>` ; } return `<span style="color:navy">Sub Total ${ params . value }</span>` ; } return params . value ; } , } , } , groupIncludeFooter : true , groupIncludeTotalFooter : true , animateRows : true , rowData : getData ( ) , } ; document . addEventListener ( 'DOMContentLoaded' , function ( ) { var gridDiv = document . querySelector ( '#myGrid' ) ; new agGrid . Grid ( gridDiv , gridOptions ) ; } ) ;