【问题标题】:ag-grid Angular "colDef.cellRendererFramework.component is deprecated"ag-grid Angular “colDef.cellRendererFramework.component 已弃用”
【发布时间】:2019-08-28 19:38:12
【问题描述】:

由于之前版本的 ag-grid 我们可以像这样将组件作为依赖项传递到我们的 cellRendererFramework 中:

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

这是取自 ag-grid blog 的示例。

不幸的是,第 9 版给了我一个弃用的警告:

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

现在有什么推荐的方法来实现这一点吗?我在 ag-grid 的变更日志中找不到任何关于此的内容。

【问题讨论】:

    标签: ag-grid ag-grid-ng2


    【解决方案1】:

    对,与父组件通信的诀窍是使用上下文对象:

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

    取自Simple Dynamic Component example

    【讨论】:

      【解决方案2】:

      你错过了博客的这一部分吗?

      代替:

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

      您现在只需要这样做:

      {
          headerName: "Clickable Component",
          field: "name",
          cellRendererFramework: ClickableParentComponent,
          width: 250
      }
      

      【讨论】:

      • 依赖怎么传入?我在您的代码中没有看到它。
      • 据我了解,你不需要再传递依赖了
      • 我正在寻找的答案是目前推荐的传递依赖关系的方法,如果不是现在不推荐使用的方法。告诉我我不必这样做真的没有帮助。
      • 目前的建议似乎从他们的文档中非常清楚......看看第二个例子here
      • 在第二个例子中没有传入依赖类。那么'ClickableParentComponent'如何与'ClickableComponent'对话?
      猜你喜欢
      • 2019-11-13
      • 2018-10-26
      • 2020-03-07
      • 1970-01-01
      • 2021-09-03
      • 2022-10-19
      • 1970-01-01
      • 2018-11-27
      • 2018-11-03
      相关资源
      最近更新 更多