Angular Data GridKey Features

The page provides an overview of and introduction to popular features available in AG Grid. Learn how to use Community features, configure and customise themes, and explore advanced Enterprise features.

Angular Data Grid quick start video tutorial thumbnail

The following sections assume a level of familiarity with common Data Grid concepts. If you're new to Angular Data Grids in general, we recommend starting with our Introductory Tutorial instead.

Showing Data

Mapping Values

The field or valueGetter attributes Map Data to Columns. A field maps to a field in the data. A Value Getter is a function callback that returns the cell value.

The headerName provides the title for the header. If missing the title is derived from field.

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    { headerName: "Make & Model", valueGetter: p => p.make + ' ' + p.model},
    { field: "price" },
];

Text Formatting

Format text for cell content using a Value Formatter.

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    { field: "price", valueFormatter: p => '£' + p.value.toLocaleString() },
];

Cell Components

Add buttons, checkboxes or images to cells with a Cell Component.

@Component({
    standalone: true,
    template: `<button (click)="buttonClicked()">Push Me!</button>`,
})
export class CustomButtonComponent implements ICellRendererAngularComp {
    agInit(params: ICellRendererParams): void {}
    refresh(params: ICellRendererParams) {
        return true;
    }
    buttonClicked() {
        alert("clicked");
    }
}

columnDefs: ColDef[] = [
    { field: "button", cellRenderer: CustomButtonComponent },
    // ...
];

Resizing Columns

Columns are Resized by dragging the Column Header edges. Additionally assign flex values to allow columns to flex to the grid width.

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    { field: "make", flex: 2 }, //This column will be twice as wide as the others
    { field: "model", flex: 1 },
    { field: "price", flex: 1 },
    { field: "electric", flex: 1 }
];

Example

This example demonstrates mapping and formatting values, cell components, and resizing columns.

Working with Data

By default, the row data is used to infer the Cell Data Type. The cell data type allows grid features, such as filtering and editing, to work without additional configuration.

Filtering

Column Filters are embedded into each column menu. These are enabled using the filter attribute. The filter type is inferred from the cell data type.

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    { field: "make", filter: true },
];

There are 5 Provided Filters which can be set through this attribute. You can also create your own Custom Filter.

Floating Filters embed the Column Filter into the header for ease of access.

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    { field: "make", filter: true, floatingFilter: true },
];

Editing

Enable Editing by setting the editable attribute to true. The cell editor is inferred from the cell data type.

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    { field: "make", editable: true },
];

Set the cell editor type using the cellEditor attribute. There are 7 Provided Cell Editors which can be set through this attribute. You can also create your own Custom Editors.

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    {
        field: "make",
        editable: true,
        cellEditor: 'agSelectCellEditor',
        cellEditorParams: {
            values: ['Tesla', 'Ford', 'Toyota'],
        },
    },
];

Sorting

Data is Sorted by clicking the column headers. Sorting is enabled by default.

Row Selection

Row Selection is enabled using the rowSelection attribute.

<ag-grid-angular
    [columnDefs]="columnDefs"
    [rowSelection]="rowSelection"
    /* other grid options ... */ />

// Column Definitions: Defines the columns to be displayed.
this.columnDefs = [
    { field: "make" },
];
this.rowSelection = {
    mode: 'multiRow',
};

Pagination

Enable Pagination by setting pagination to be true.

<ag-grid-angular
    [pagination]="pagination"
    [paginationPageSize]="paginationPageSize"
    [paginationPageSizeSelector]="paginationPageSizeSelector"
    /* other grid options ... */ />

this.pagination = true;
this.paginationPageSize = 500;
this.paginationPageSizeSelector = [200, 500, 1000];

Example

This example demonstrates filtering, editing, sorting, row selection, and pagination.

Themes & Style

Themes

Grid Themes define how the grid looks (colors, font, spacing etc). The default theme is called Quartz. You can choose a different theme, or customise a built-in theme by changing parameters. Here we create a new theme based on Quartz:

import { themeQuartz } from "ag-grid-community"; // or themeBalham, themeAlpine

const myTheme = themeQuartz.withParams({
    /* Low spacing = very compact */
    spacing: 2,
    /* Changes the color of the grid text */
    foregroundColor: 'rgb(14, 68, 145)',
    /* Changes the color of the grid background */
    backgroundColor: 'rgb(241, 247, 255)',
    /* Changes the header color of the top row */
    headerBackgroundColor: 'rgb(228, 237, 250)',
    /* Changes the hover color of the row*/
    rowHoverColor: 'rgb(216, 226, 255)',
});

// ...
    template: `<div style="height: 100%; box-sizing: border-box;">
        <ag-grid-angular
            // ...
            [theme]="theme"
            />
    </div>`,
// ...
public theme = myTheme;

Theme Builder

Use the Theme Builder to create a custom theme with our visual editor. Browse and customise 100's of theme parameters and preview the changes in real-time. Automatically generate the theme code to copy & paste into your application.

Figma

If you are designing within Figma, you can use the AG Grid Design System to replicate the Quartz and Alpine AG Grid themes within Figma. These default themes can be extended with Figma variables to match any existing visual design or create entirely new AG Grid themes. These can then be exported and generated into new AG Grid themes.

Cell Style

Define rules to apply Styling to Cells using cellClassRules. This can be used, for example, to set cell background colour based on its value.

.rag-green {
    background-color: #33cc3344;
}
<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [{
    field: 'electric',
    cellClassRules: {
        // apply green to electric cars
        'rag-green': params => params.value === true,
    }
}];

Row Style

Define rules to apply Styling to Rows using rowClassRules. This allows changing style (e.g. row colour) based on row values.

.rag-red {
    background-color: #cc222244;
}
<ag-grid-angular
    [rowClassRules]="rowClassRules"
    /* other grid options ... */ />

this.rowClassRules = {
    // apply red to Ford cars
    'rag-red': params => params.data.make === 'Ford',
};

Example

This example demonstrates cell style and row style.

Enterprise Features (e)

AG Grid comes in two forms:

  • AG Grid Community: Free for everyone, including production use - no license required.
  • AG Grid Enterprise: Requires a license to use in production. Free to test locally, or request a trial to test in production.

To learn more about the differences between AG Grid Community and Enterprise, when to use each version, and how to access our free trial or purchase a license, see the Community vs Enterprise docs.

Integrated Charts (e)

Integrated Charts allow users to build and customise charts directly within the grid.

Enable Integrated Charts by setting enableCharts to true. Set cellSelection to true to allow users to create charts by selecting a range of cells:

<ag-grid-angular
    [enableCharts]="enableCharts"
    [cellSelection]="cellSelection"
    /* other grid options ... */ />

this.enableCharts = true;
this.cellSelection = true;

Grouping Rows (e)

Enable Row Grouping by setting rowGroup to true:

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    { field: 'country', rowGroup: true },
    // ...
];

Aggregating Rows (e)

Enable Aggregation by setting aggFunc to one of sum, min, max, count, avg, first, or last:

<ag-grid-angular
    [columnDefs]="columnDefs"
    /* other grid options ... */ />

this.columnDefs = [
    { field: 'gold', aggFunc: 'sum' },
    // ...
];

Pivoting Rows (e)

Enable Pivoting by setting pivotMode to true. Define pivot columns by setting pivot to true:

<ag-grid-angular
    [columnDefs]="columnDefs"
    [pivotMode]="pivotMode"
    /* other grid options ... */ />

this.columnDefs = [
    { field: 'sport', pivot: true },
];
this.pivotMode = true;

Displaying Tree Data (e)

Tree Data provides a way to supply the grid with structured hierarchical data.

Enable Tree Data by setting treeData to true. Provide a getDataPath callback to configure the Row Hierarchy:

<ag-grid-angular
    [treeData]="treeData"
    [getDataPath]="getDataPath"
    /* other grid options ... */ />

this.treeData = true;
this.getDataPath = data => data.path;

Displaying Tool Panels (e)

The grid provides Tool Panels for Columns and Filters. You can also provide Custom Tool Panels.

To enable Column and Filter Tool Panels, set sideBar to true. To display only the Column or Filter Tool Panel, set sideBar to 'columns' or 'filters':

<ag-grid-angular
    [sideBar]="sideBar"
    /* other grid options ... */ />

this.sideBar = true;

Example

This example demonstrates Integrated Charting, Row Grouping, Pivoting, Aggregation and Tool Panels: