import { ColDef , GridOptions , GridReadyEvent } from '@ag-grid-community/core' ; const columnDefs = [ { checkboxSelection : true , field : 'athlete' , minWidth : 200 } , { field : 'country' , minWidth : 200 } , { headerName : 'Group' , valueGetter : 'data.country.charAt(0)' } , { field : 'sport' , minWidth : 150 } , { field : 'gold' , hide : true } , { field : 'silver' , hide : true } , { field : 'bronze' , hide : true } , { field : 'total' , hide : true } , ] ; const gridOptions = { defaultColDef : { sortable : true , filter : true , resizable : true , minWidth : 100 , flex : 1 , } , suppressRowClickSelection : true , columnDefs : columnDefs , rowSelection : 'multiple' , onGridReady : function ( params ) { ( document . getElementById ( 'selectedOnly' ) as HTMLInputElement ) . checked = true ; } , } ; function onBtExport ( ) { gridOptions . api ! . exportDataAsExcel ( { onlySelected : ( document . querySelector ( '#selectedOnly' ) as HTMLInputElement ) . checked , } ) ; } document . addEventListener ( 'DOMContentLoaded' , ( ) => { const gridDiv = document . querySelector ( '#myGrid' ) ; new agGrid . Grid ( gridDiv , gridOptions ) ; fetch ( 'https://www.ag-grid.com/example-assets/small-olympic-winners.json' ) . then ( response => response . json ( ) ) . then ( data => gridOptions . api ! . setRowData ( data . filter ( ( rec ) => rec . country != null ) ) ) ; } ) ;