Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 390
Sergey Smirnov Avatar asked Nov 12 '19 15:11

Sergey Smirnov


2 Answers

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.

like image 57
Brian Roadifer Avatar answered Nov 17 '22 06:11

Brian Roadifer


I have been using the community version with no issues. I just downloaded a trial of enterprise and everything changed. When I ran into this issue, I learned that [modules]="modules" is required on the grid. That requires these two lines to be included on the component:

import { AllModules } from '@ag-grid-enterprise/all-modules';
modules: Module[] = AllModules;

I've never had to do this before in community version, but it quickly corrected the issue. The answer that was accepted above is stating what needs to happen when your application is integrating only individual modules. Per the documentation: "If you choose to select individual modules then at a minimum the a Row Model need to be specified. After that all other modules are optional depending on your requirements".

like image 4
Briana Finney Avatar answered Nov 17 '22 06:11

Briana Finney