import { GridOptions , ICellRendererParams , IDatasource , IGetRowsParams } from '@ag-grid-community/core' ; const gridOptions = { columnDefs : [ { headerName : 'ID' , maxWidth : 100 , valueGetter : 'node.id' , cellRenderer : 'loadingRenderer' , } , { field : 'athlete' , minWidth : 200 } , { field : 'age' } , { field : 'country' , minWidth : 200 , checkboxSelection : true } , { field : 'year' } , { field : 'date' , minWidth : 150 } , { field : 'sport' , minWidth : 150 } , { field : 'gold' } , { field : 'silver' } , { field : 'bronze' } , { field : 'total' } , ] , defaultColDef : { flex : 1 , minWidth : 100 , resizable : true , } , components : { loadingRenderer : function ( params ) { if ( params . value !== undefined ) { return params . value ; } else { return '<img src="https://www.ag-grid.com/example-assets/loading.gif">' ; } } , } , rowBuffer : 0 , rowSelection : 'multiple' , isRowSelectable : function ( rowNode ) { return rowNode . data ? rowNode . data . country === 'United States' : false ; } , rowModelType : 'infinite' , cacheBlockSize : 100 , cacheOverflowSize : 2 , maxConcurrentDatasourceRequests : 2 , infiniteInitialRowCount : 1 , maxBlocksInCache : 2 , } ; 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 ( function ( data ) { var dataSource = { rowCount : undefined , getRows : function ( params ) { setTimeout ( function ( ) { var rowsThisPage = data . slice ( params . startRow , params . endRow ) ; var lastRow = - 1 ; if ( data . length <= params . endRow ) { lastRow = data . length ; } params . successCallback ( rowsThisPage , lastRow ) ; } , 500 ) ; } , } ; gridOptions . api ! . setDatasource ( dataSource ) ; } ) ; } ) ;