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

490
Views
Open Options menu on click event of icon in ag-grid in angular

I have an icon inside ag-grid cell and on the click of icon I am trying to open a popup near the icon which will have edit and delete as below:

enter image description here

I have code as below:

<ag-grid-angular
  style="padding-top: 10px;" 
  [rowData]="rowData" 
  [columnDefs]="columnDefs" 
  (gridReady)="onGridReady($event)"
  [pagination]="true" 
  [paginationPageSize]="5"
  [defaultColDef]="defaultColDef"  
  domLayout="autoHeight" 
>
</ag-grid-angular>

public columnDefs: ColDef[] = [{
{
          headerName: 'Options',
          field: 'propId',
          cellRenderer: function (params: any) {
            let propId = params.value;
            const eDiv = document.createElement('div');
            var optionsOnHtml = '<i class="icon-options" style="color:#0672CB; margin-right: 10px;padding-right:10px" aria-hidden="true"></i>';
            eDiv.innerHTML = optionsOnHtml;
            
            const optionsIcon = eDiv.querySelectorAll('.icon-options')[0];
            
            optionsIcon.addEventListener('click', () => {
              // Code here
            });
            return eDiv;
          },
          cellStyle: {
            borderRightColor: '#e1e1e1',
            borderRightWidth: '1px',
            borderRightStyle: 'solid',
          },
        },];

I wanted to know how can I add these two options along with propId so that I can edit / delete the record with propId.

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

0

You will need to add getContextMenuItems in your ag-grid-angular.

<ag-grid-angular
..
[getContextMenuItems]="getContextMenuItems"
></ag-grid-angular>

Then add something like:

getContextMenuItems(params) {
    let result = [
        {
          name: "Edit",
          action: () => { this.openEdit(params) }
        },
        {
          name: "Delete",
          action: () => { this.openDelete(params) }
        }
      ];
    });
    return result;
  }

And then finally bind this where you are initializing the grid.

 this.getContextMenuItems = this.getContextMenuItems.bind(this);

This link should help

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!