Search code examples
angularag-gridag-grid-angular

How to import ag-grid-enterprise in my Angular 7 project


I wanted to use server-side-row-model in my Angular 7 project where I use ag-grid. In my package.json I found ag-grid-enterprise is already there as

"ag-grid-enterprise": "^20.0.0"

But inside node-modules/ag-grid-enterprise I do not find server-side-row-model. In the documentation it is advised as:

@ag-grid-enterprise/server-side-row-model": "~22.0.0"

So I try that in package.json. But it cannot import, neither I do find @ag-grid-enterprise inside node-modules.Neither can it import:

import { ServerSideRowModelModule } from '@ag-grid-enterprise/server-side-row-model';

Solution

  • Short answer

    You do not need @ag-grid-enterprise/server-side-row-model if you've already had ag-grid-enterprise. Besides, make sure you also have the following packages:

    • ag-grid-angular to make AgGrid works with angular
    • ag-grid-community: to include all community features. ag-grid-enterprise only includes additional feature for enterprise users
    "ag-grid-angular": "^20.0.0",
    "ag-grid-community": "^20.0.1",
    "ag-grid-enterprise": "^20.0.0",
    

    Don't forget to register your module in your app.module.ts

    import { AgGridModule } from "ag-grid-angular";
    import 'ag-grid-enterprise';
    
    @NgModule({
      declarations: [AppComponent],
      imports: [BrowserModule, AgGridModule.withComponents([])],
      providers: [],
      bootstrap: [AppComponent]
    })
    export class AppModule {}
    

    Longer answer

    There are 2 ways of importing AgGrid. Using package or module.

    "ag-grid-enterprise": "^20.0.0"
    

    This one is a package which contains all of the feature. this is the easiest way to import

    @ag-grid-enterprise/server-side-row-model": "~22.0.0"
    @ag-grid-enterprise/xxxxx
    

    This one is a separate module. It allows you to cherry-pick only the features you need. It helps reduce the bundle size but needs more time to setup correctly

    You cannot mix 2 of them together. Either use package or module.