Failed to call services in agGrid (Angular2) using cell renderer

I use ag-grid to display a list of users. If I edit user data, then I want to click the refresh button in the grid to edit the corresponding user data.

This is the coloumn header in ag_grid

{ headerName: 'Update', field: "update", width: 80, cellRenderer:this.updateRenderFunction} 

I use cell rendering

 updateRenderFunction(params){ var eSpan = document.createElement('button'); eSpan.innerHTML = "Update"; var data = params.node.data; eSpan.addEventListener('click',()=>{ //here i want to call service }) return eSpan; } 
+5
source share
1 answer

Try it, it worked for me ... give bind (this) after updateRenderFunction, as shown below.

 { headerName: 'Update', field: "update", width: 80, cellRenderer:this.updateRenderFunction.bind(this)} 
+2
source

All Articles