Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

499
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda