ag-grid Angular “colDef.cellRendererFramework.component is deprecated”

◇◆丶佛笑我妖孽 提交于 2019-12-13 03:13:40

问题


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.


回答1:


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




回答2:


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
}


来源:https://stackoverflow.com/questions/44025481/ag-grid-angular-coldef-cellrendererframework-component-is-deprecated

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!