ag-grid Angular “colDef.cellRendererFramework.comp

2019-09-14 21:04发布

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.

2条回答
Explosion°爆炸
2楼-- · 2019-09-14 21:52

did you miss this part of the blog?

instead of:

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

You now only need to do this:

{
    headerName: "Clickable Component",
    field: "name",
    cellRendererFramework: ClickableParentComponent,
    width: 250
}
查看更多
爷的心禁止访问
3楼-- · 2019-09-14 21:54

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

查看更多
登录 后发表回答