import { GridOptions } from '@ag-grid-community/core' ; const gridOptions = { columnDefs : [ { field : 'athlete' } , { field : 'age' , width : 100 } , { field : 'country' , sort : 'asc' } , { field : 'year' } , { field : 'date' } , { field : 'sport' } , { field : 'gold' } , { field : 'silver' } , { field : 'bronze' } , { field : 'total' } , ] , defaultColDef : { width : 170 , sortable : true , } , postSort : rowNodes => { let nextInsertPos = 0 ; for ( let i = 0 ; i < rowNodes . length ; i ++ ) { const country = rowNodes [ i ] . data . country ; if ( country === 'Ireland' ) { rowNodes . splice ( nextInsertPos , 0 , rowNodes . splice ( i , 1 ) [ 0 ] ) ; nextInsertPos ++ ; } } } , } ; document . addEventListener ( 'DOMContentLoaded' , ( ) => { const 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 ) ; } ) ; } ) ;