1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

ag-grid: Using Grid Event CellClicked for specific column - cannot access "this"

Discussão em 'Angular' iniciado por garg10may, Setembro 24, 2024.

  1. garg10may

    garg10may Guest

    I have a column in grid which when clicked I am trying to access some method of class but the this context has changed and not available. Ex -

    export class PreTflGridComponent implements OnInit {

    columnDefs = [
    {onCellClicked: this.editCellClicked}
    ];

    constructor() { }

    method(): void {
    console.log('working');
    }

    editCellClicked(params) {
    this.method();
    }

    }


    Error:

    ERROR TypeError: this.method is not a function


    How can I access the methods/properties once the this context has changed.

    Refer below for the exact issue https://stackblitz.com/edit/angular-vwgcc2, if you will click the column make and open up console then it would show the error I am facking.

    Continue reading...

Compartilhe esta Página