import { GridOptions , ICellRendererComp , ICellRendererParams } from '@ag-grid-community/core' ; const gridOptions = { columnDefs : [ { field : 'athlete' , minWidth : 180 } , { field : 'age' } , { field : 'country' , minWidth : 160 } , { field : 'year' } , { field : 'date' , minWidth : 160 } , { field : 'sport' , minWidth : 180 } , { field : 'gold' } , { field : 'silver' } , { field : 'bronze' } , { field : 'total' } , ] , defaultColDef : { flex : 1 , minWidth : 100 , editable : true , cellRenderer : 'singleClickEditRenderer' , } , suppressClickEdit : true , components : { singleClickEditRenderer : getRenderer ( ) , } , } ; function getRenderer ( ) { class CellRenderer implements ICellRendererComp { eGui : any ; eButton : any ; params ! : ICellRendererParams ; buttonClickListener ! : ( ) => void ; createGui ( ) { const template = '<span><button id="theButton" style="height: 39px">#</button><span id="theValue" style="padding-left: 4px;"></span></span>' ; const tempDiv = document . createElement ( 'div' ) ; tempDiv . innerHTML = template ; this . eGui = tempDiv . firstElementChild ; } init ( params ) { this . createGui ( ) ; this . params = params ; const eValue = this . eGui . querySelector ( '#theValue' ) ; eValue . innerHTML = params . value ; this . eButton = this . eGui . querySelector ( '#theButton' ) ; this . buttonClickListener = this . onButtonClicked . bind ( this ) ; this . eButton . addEventListener ( 'click' , this . buttonClickListener ) ; } onButtonClicked ( ) { const startEditingParams = { rowIndex : this . params . rowIndex , colKey : this . params . column ! . getId ( ) , } ; this . params . api . startEditingCell ( startEditingParams ) ; } getGui ( ) { return this . eGui ; } refresh ( ) { return false ; } destroy ( ) { this . eButton . removeEventListener ( 'click' , this . buttonClickListener ) ; } } return CellRenderer ; } 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 ) ) ; } ) ;