Search code examples
ag-gridag-grid-ng2

ag-grid Angular "colDef.cellRendererFramework.component is deprecated"


Since previous version of ag-grid we could pass a Component as a dependency into our cellRendererFramework like this:

{
    headerName: "Clickable Component",
    field: "name",
    cellRendererFramework: {
        component: ClickableParentComponent,
        dependencies: [ClickableComponent]
    },
    width: 200
}

this is an example taken from this ag-grid blog.

Unfortunatelly version 9 gives me a deprecated warning about this:

colDef.cellRendererFramework.component is deprecated - please refer to https://ag-grid.com/best-angular-2-data-grid/

Is there any recommended way now to achieve this? I couldn't find anything about this in ag-grid's changelogs.


Solution

  • Right, the trick to communicate with the parent component is using the context object:

    this.gridOptions = <GridOptions>{
        context: {
            componentParent: this
        }
    };
    

    Taken from Simple Dynamic Component example