import { GridOptions , IServerSideDatasource } from '@ag-grid-community/core' ; declare var FakeServer ; const gridOptions = { columnDefs : [ { field : 'id' , maxWidth : 75 } , { field : 'athlete' , minWidth : 190 } , { field : 'age' } , { field : 'year' } , { field : 'gold' } , { field : 'silver' } , { field : 'bronze' } , ] , defaultColDef : { flex : 1 , minWidth : 90 , resizable : true , } , rowModelType : 'serverSide' , serverSideStoreType : 'partial' , pagination : true , paginationPageSize : 10 , cacheBlockSize : 10 , animateRows : true , } ; 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 idSequence = 1 ; data . forEach ( function ( item ) { item . id = idSequence ++ ; } ) ; var fakeServer = new FakeServer ( data ) ; var datasource = getServerSideDatasource ( fakeServer ) ; gridOptions . api ! . setServerSideDatasource ( datasource ) ; } ) ; } ) ; function getServerSideDatasource ( server ) { return { getRows : function ( params ) { console . log ( '[Datasource] - rows requested by grid: ' , params . request ) ; var response = server . getData ( params . request ) ; setTimeout ( function ( ) { if ( response . success ) { params . success ( { rowData : response . rows , rowCount : response . lastRow } ) ; } else { params . fail ( ) ; } } , 200 ) ; } , } ; }