0

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.

George Knap
  • 843
  • 9
  • 30

2 Answers2

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

Kelvin Low
  • 390
  • 6
  • 22
George Knap
  • 843
  • 9
  • 30
0

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
}
Jarod Moser
  • 7,022
  • 2
  • 24
  • 52
  • How do you pass in the dependency? I don't see it in your code. – George Knap May 18 '17 at 17:19
  • As I understand it, you don't need to pass the dependency any more – Jarod Moser May 18 '17 at 17:41
  • The answer I am looking for is what is currently the recommended way to pass dependency if not the one that is now deprecated. Telling me I don't have to do it really doesn't help. – George Knap May 18 '17 at 19:36
  • The current recommendation seems to be very clear form their docs... take a look at the second example [here](https://www.ag-grid.com/example-angular-dynamic/#dynamic&gsc.tab=0) – Jarod Moser May 18 '17 at 21:25
  • At the second example there is no dependecy class passed in.How does the 'ClickableParentComponent' talks to 'ClickableComponent' then? – George Knap May 19 '17 at 11:30
  • I am no angular guru... but it looks like there was a `module` created that gets wrapped into angular... Ag-grid only knows that it needs `ClickableParentComponent`, while angular knows about the module and the extra dependencies... perhaps [this page of the angular docs](https://angular.io/docs/ts/latest/guide/ngmodule.html) sheds more light on the subject – Jarod Moser May 23 '17 at 18:23