Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
How to write click event in inside of cellrenderer angular ag grid

enter code hereI am trying to create edit and delete buttons in same column for every row using angular ag grid. To display the edit and delete buttons, I am using icons. I am able to display the remove and edit icons for every row in ag grid, but i am failing to click those icons. Below are the respective images of that. I tried to click event inside of button but it was not worked, I tried to write click event in icon tag also but it is also not worked. Below is my code which i am using



about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

You can follow this approach to create a click event in cell renderer.

First : Create Button Cell

create button cell renderer as an Angular component that implements the ICellRendererAngularComp interface as follows :

@Component({
  selector: 'btn-cell-renderer',
  template: `
    <button (click)="handleClickEvent($event)">Click me</button>
  `,
})
export class BtnCellRenderer implements ICellRendererAngularComp
{
  private params: any;

  agInit(params: any): void {
    this.params = params;
  }

  handleClickEvent() {
    this.params.clicked(this.params.value);
  } 
 
}

The params object is accessed through the agInit hook.

Second: Register the BtnRenderer in the app module

// app/app.modules.ts

@NgModule({
  imports: [
    BrowserModule,
    FormsModule,
    HttpClientModule,
    AgGridModule.withComponents([BtnCellRenderer]),
  ],
  declarations: [AppComponent, BtnCellRenderer],
  bootstrap: [AppComponent],
})

Third: Use the renderer Use the renderer in your component as follows

// app/app.component.ts

this.columnDefs = [
      {
        field: 'action',
        cellRenderer: 'btnCellRenderer',
        cellRendererParams: {
          clicked: function(field: any) {
            alert(`${field} was clicked`);
          }
        },
        minWidth: 100,
      }
     
      ];
      
      this.frameworkComponents = {
      btnCellRenderer: BtnCellRenderer
    };
about 4 years ago · Juan Pablo Isaza Report

0

You can follow kplus answer and in order to display two buttons create two renderer and bind them separately with edit and delete button in your columnDefs.

  columnDefs = [
  {
      field: 'edit', cellRenderer: 'editRenderer',
      headerClass: 'my-header-class',
      cellRendererParams: {
        onClick: this.onClickEdit.bind(this)
      }
    },
    {
      field: 'Delete',cellRenderer: 'deleteRenderer',
      headerClass: 'my-header-class',
      cellRendererParams: {
        onClick: this.onClickDelete.bind(this)
      }
    }];
    
     onClickEdit(params) {
     //code
     }
     
     onClickDelete(params) {
     //code
     }
     
     
     
    constructor() {
    this.frameworkComponents = {
      editRenderer: EditComponent,
      deleteRenderer: DeleteCompoenent
    }
     
     

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!