Trouble setting up sample table. "Could not find matching row model for rowModelType clientSide"

Sergey Smirnov picture Sergey Smirnov · Nov 12, 2019 · Viewed 8.7k times · Source

I've been going through the "Getting Started" tutorial for the ag-grid on the fresh project. Completed all the steps but got an error saying

ag-Grid: could not find matching row model for rowModelType clientSide
ag-Grid: Row Model "Client Side" not found. Please ensure the ClientSideRowModelModule is loaded using: import '@ag-grid-community/client-side-row-model';

Compared all my code with examples provided in the tutorial and some plunker examples, and didn't notice any differences. Tried importing ClientSideRowModelModule to the app.module but interfaces did not match with what angular requested, so it didn't work. I'm out of ideas and failed to find any info on how to fix it.

app.module.ts:

    ... imports: [
    BrowserModule,
    AppRoutingModule,
    AgGridModule.withComponents([])
  ],...

app.cpmponent.html:

<ag-grid-angular 
style="width: 500px; height: 500px;" 
class="ag-theme-balham"
[rowData]="rowData" 
[columnDefs]="columnDefs"
 >
</ag-grid-angular>

app.component.ts:

    ...columnDefs = [
      {headerName: 'Make', field: 'make' },
      {headerName: 'Model', field: 'model' },
      {headerName: 'Price', field: 'price'}
  ];

  rowData = [
      { make: 'Toyota', model: 'Celica', price: 35000 },
      { make: 'Ford', model: 'Mondeo', price: 32000 },
      { make: 'Porsche', model: 'Boxter', price: 72000 }
  ];...

I'm using Angular: 8.2.10, Angular CLI: 8.2.2, npm: 6.9.0

Answer

Brian Roadifer picture Brian Roadifer · Nov 13, 2019

In your app.component.ts, you first need to import the ClientSideRowModelModule

import { ClientSideRowModelModule } from '@ag-grid-community/client-side-row-model';

Then inside the AppComponent class, you need to create a module array variable like this:

modules: Module[] = [ClientSideRowModelModule];

Finally, in your app.component.html, you need to bind it to the ag-grid-angular component

<ag-grid-angular 
style="width: 500px; height: 500px;" 
class="ag-theme-balham"
[rowData]="rowData" 
[columnDefs]="columnDefs"
[modules]="modules"
 >
</ag-grid-angular>

For further resource look at AgGrid's documentation, it is step 3 on installing AgGrid Modules.