Stack-Overflow-User-0
Stack-Overflow-User-0

Reputation: 21

cellRendererFramework no component factory found ag-grid angular2

Trying to use cellRendererFramework(v13.1.2) with angular2 but getting this error instead:

ProductComponentComponent.html:7 ERROR Error: No component factory found for [object Object]. Did you add it to @NgModule.entryComponents? at noComponentFactoryError (core.es5.js:3202)

Is cellRendererFramework not supported in ag-grid v13.1.2? Or is there some other issue.

Something similar has been asked earlier but didn't found any helpful answer.Please help with this. Thanks in advance.

Upvotes: 2

Views: 3506

Answers (5)

Abdul Rehman Sayed
Abdul Rehman Sayed

Reputation: 6672

Here's what I did. ( Version 19.1.1).

In app.module.ts, Import your renderers with AgGridModule.withComponents as

    @NgModule({
      declarations: [
        AppComponent
      ],
      imports: [
         ...
           AgGridModule.withComponents([
              ActionRendererComponent,
              YesnoRendererComponent, 
              StatusRendererComponent
          ])
      ],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule { }

Upvotes: 2

windmaomao
windmaomao

Reputation: 7680

Couple of things as mentioned in previous answers, I got it working by doing couple of things.

in module definition, add your renderer for both declarations and entryComponents.

```

declarations: [ReportHyperlinkCellRenderer],
entryComponents: [ReportHyperlinkCellRenderer],

```

define your GridOptions as

```

{
  frameworkComponents: {
    "hyperlinkRenderer": ReportHyperlinkCellRenderer
  }
}

```

afterwards, your ColDef can be just simple as

```

{
  cellRenderer: "hyperlinkRenderer"
}

```

Upvotes: 0

Shubham Tiwari
Shubham Tiwari

Reputation: 713

If the above two solutions are not working then it is highly likely that you are passing string to ComponentFactoryResolver when loading data from server but it should be component type.

Check this url : Stack overflow

Upvotes: 0

steverippl
steverippl

Reputation: 378

I added the component to the @NgModule's entryComponents, as the error message points to. For example...

@NgModule({
imports: [
    CommonModule,
    SharedModule,
    ...
],
declarations: [
    ...
    myRendererComponent,
    ...
],
providers: [
    ...
],
entryComponents: [
    myRendererComponent
]

See https://hassantariqblog.wordpress.com/2017/02/12/angular2-error-no-component-factory-found-did-you-add-it-to-ngmodule-entrycomponents/

Upvotes: 1

remborg
remborg

Reputation: 548

It might be a bit late but I ended up here while having the same issue. Here is how I fixed it, in the grid options:

this.gridOptions = <GridOptions>{
  ...
  frameworkComponents: {
    "checkboxRenderer": CheckboxCellRendererComponent
  }
}

then in the column defs:

{
  field: "present",
  headerName: "User was present",
  cellRenderer: "checkboxRenderer"
}

Upvotes: 0

Related Questions