Angular Agrid Delete Sede

‘ve tried to add a button delete on my aggrid tabel, but when i click on it, none method was called, why ?

I’ve tried to do a lot of test,
put the column definition on my html, but doesn’t work, also i’ve tried to change the way to define the delet colomun like remove ICellRendererAngularComp, and tried without, but i’ve got the same result, the method not was call. I also using an IA like CODY or phind, but i’ve receive a solution.
Please help me, i’m a bakcend debeloper and i need to resolve this problem

My ts :

import { Component, OnInit, ViewChild } from '@angular/core';
import { AgGridAngular } from 'ag-grid-angular';
import { ColDef, ColumnApi, GridApi, ICellRendererParams, ValueGetterParams } from 'ag-grid-community';
import { SediEsterneService } from '../action/sedi-esterne.action';
import { SediEsterne } from '../interface/interface.sedi-esterne';
import { SedEsterneAggiunSedeComponent } from '../sedi-esterne-aggiun-sede/sedi-esterne-aggiun-sede.component';
import { ICellRendererAngularComp } from 'ag-grid-angular';

import {MatButtonModule} from '@angular/material/button';

@Component({
  selector: 'sedi-esterne',
  standalone: true, // Mantieni standalone: true
  imports: [AgGridAngular, MatButtonModule],
  templateUrl: './sedi-esterne.component.html',
  styleUrls: ['./sedi-esterne.component.scss']
})
export class SediEsterneComponent implements OnInit, ICellRendererAngularComp {
  private params: any;
  gridApi: any;
  gridColumnApi: any;

  defaultColDef = {
    filter: true, // Abilita il filtro per tutte le colonne
    sortable: true, // Abilita l'ordinamento per tutte le colonne
    resizable: true // Abilita la ridimensionabilità delle colonne
  };
  columnDefs: ColDef[] = [
    {
      headerName: "Azione",
      field: "azione",
      cellRenderer: this.removeRowRenderer.bind(this),
      pinned: 'left'
    },
    {
      headerName: "Sede",
      field: "sede",
      pinned: 'left',
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true

    },
    {
      headerName: "Indirizzo",
      field: "indirizzo",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "Tipo",
      field: "tipo",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "NetSede23",
      field: "netSede23",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "IpOutsideFirewall29",
      field: "ipOutsideFirewall29",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "Firewall",
      field: "firewall",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "CitrixMgmt",
      field: "citrixMgmt",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "IpCitrixIntPri",
      field: "ipCitrixIntPri",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "IpCpePri",
      field: "ipCpePri",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "LaPri",
      field: "laPri",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "TipologiaCollPri",
      field: "tipologiaCollPri",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "IpCitrixIntSec28",
      field: "ipCitrixIntSec28",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "IpCpeSec",
      field: "ipCpeSec",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "LaSec",
      field: "laSec",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "TipologiaCollSec",
      field: "tipologiaCollSec",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "IpCitrixIntTer28",
      field: "ipCitrixIntTer28",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "IpCpeTer",
      field: "ipCpeTer",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "LaTer",
      field: "laTer",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "TipologiaCollTer",
      field: "tipologiaCollTer",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "DataMigr",
      field: "dataMigr",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "Referenti",
      field: "referenti",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "Note",
      field: "note",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "UpgPri",
      field: "upgPri",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "UpgSec",
      field: "upgSec",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "CitrixSn",
      field: "citrixSn",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
    {
      headerName: "CitrixLicHostId",
      field: "citrixLicHostId",
      sortable: true, // Abilita l'ordinamento
      filter: true,   // Abilita il filtro
      editable: true
    },
  ];


  rowData!: SediEsterne[];

  constructor(private sediEsterneService: SediEsterneService) { }
  agInit(params: ICellRendererParams): void {
    this.params = params;
  }

  refresh(params: ICellRendererParams): boolean {
    this.params = params;
    return true; // Restituisci true per ridisegnare il componente
  }

  onGridReady(params: { api: GridApi; columnApi: ColumnApi }): void {
    this.gridApi = params.api;
    this.gridColumnApi = params.columnApi;
    console.log("api", params.api);
    console.log("column api", params.columnApi);
  }


  onCellEditingStopped(event: any): void {
    console.log('Valore della cella modificata:', event.data);
  }

  // O utilizza onRowEditingStopped per ottenere tutti i dati della riga modificata
  onRowEditingStopped(event: any): void {
    console.log('Dati della riga modificata:', event.data);
    const sedeDaModificare = event.data;
    this.sediEsterneService.editSede(sedeDaModificare).subscribe({
      next: (success) => {
        console.log('Aggiornamento completato con successo:', success);
        // Qui puoi aggiungere qualsiasi azione successiva, come aggiornare la UI
      },
      error: (error) => {
        console.error('Si è verificato un errore durante l'aggiornamento:', error);
        // Gestisci l'errore, ad esempio mostrando un messaggio all'utente
      }
    });
  }

  @ViewChild(AgGridAngular) agGrid!: AgGridAngular;

  removeRowRenderer(params: any) {
    return `<button class="btn btn-danger" (click)="removeRow(${params.rowIndex})">Elimina</button>`;

  }

  removeRow(rowIndex: number): void {
    const res = confirm(`Sei sicuro di voler eliminare questa riga?`);
    if (res) {
      const rowNode = this.gridApi.getRowNode(rowIndex);
      if (rowNode) {
        this.gridApi.applyTransaction({ remove: [rowNode.data] });
      }
    }
  }

  ngOnInit(): void {
    this.sediEsterneService.fetchGetSedi().subscribe({
      next: (data) => {
        this.rowData = data;
      },
      error: (err) => {
        console.error('Errore nella chiamata API', err);
      }
    });
  }

}

My HTML :

<ag-grid-angular
  class="ag-theme-alpine"
  [rowData]="rowData"
  [columnDefs]="columnDefs"
  style="height: 100vh;"
  [domLayout]="'autoHeight'"
  [editType]="'fullRow'"
  [defaultColDef]="{ resizable: true }"
  [pagination]="true"
  (gridReady)="onGridReady($event)"
  
  (rowEditingStopped)="onRowEditingStopped($event)"
  [paginationPageSize]="25">


</ag-grid-angular>

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật