Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

unable to call services in agGrid(Angular2) by cell renderer option

I am using ag-Grid for displaying the list of user .If i edit the user details,then i want to click update button in grid to edit the corresponding user details.

This is coloumn header in ag_grid

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

i am using cell renderer

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;

 }
like image 995
Naveen Kumar Avatar asked Oct 18 '22 07:10

Naveen Kumar


1 Answers

Try this it worked for me...give bind(this) after updateRenderFunction like below.

{ headerName: 'Update', field: "update", width: 80, cellRenderer:this.updateRenderFunction.bind(this)} 
like image 64
raja c Avatar answered Nov 15 '22 05:11

raja c