Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

493
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda