import { ColDef , GridOptions , ITextFilterParams } from '@ag-grid-community/core' ; function contains ( target , lookingFor ) { return target && target . indexOf ( lookingFor ) >= 0 ; } var athleteFilterParams = { filterOptions : [ 'contains' , 'notContains' ] , textFormatter : function ( r ) { if ( r == null ) return null ; return r . toLowerCase ( ) . replace ( /[àáâãäå]/g , 'a' ) . replace ( /æ/g , 'ae' ) . replace ( /ç/g , 'c' ) . replace ( /[èéêë]/g , 'e' ) . replace ( /[ìíîï]/g , 'i' ) . replace ( /ñ/g , 'n' ) . replace ( /[òóôõö]/g , 'o' ) . replace ( /œ/g , 'oe' ) . replace ( /[ùúûü]/g , 'u' ) . replace ( /[ýÿ]/g , 'y' ) ; } , debounceMs : 200 , suppressAndOrCondition : true , } as ITextFilterParams ; var countryFilterParams = { filterOptions : [ 'contains' ] , textMatcher : function ( { value , filterText } ) { var filterTextLowerCase = filterText ? filterText . toLowerCase ( ) : '' ; var valueLowerCase = value . toString ( ) . toLowerCase ( ) ; var aliases = { usa : 'united states' , holland : 'netherlands' , vodka : 'russia' , niall : 'ireland' , sean : 'south africa' , alberto : 'mexico' , john : 'australia' , xi : 'china' , } ; var literalMatch = contains ( valueLowerCase , filterTextLowerCase ) ; return ( ! ! literalMatch || ! ! contains ( valueLowerCase , aliases [ filterTextLowerCase ] ) ) ; } , trimInput : true , debounceMs : 1000 , } as ITextFilterParams ; const columnDefs = [ { field : 'athlete' , filterParams : athleteFilterParams , } , { field : 'country' , filter : 'agTextColumnFilter' , filterParams : countryFilterParams , } , { field : 'sport' , filter : 'agTextColumnFilter' , filterParams : { caseSensitive : true , defaultOption : 'startsWith' , } , } , ] ; const gridOptions = { defaultColDef : { flex : 1 , sortable : true , filter : true , } , columnDefs : columnDefs , rowData : null , } ; 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 ( data => gridOptions . api ! . setRowData ( data ) ) ; } ) ;