Angular Data Grid

Grid State

angular logo

This section covers saving and restoring the grid state, such as the filter model, selected rows, etc.

Saving and Restoring State

The initial state is provided via the grid option initialState. It is only read once when the grid is created.

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

this.initialState = {
    filter: {
        filterModel: { 
            year: {
                filterType: 'set',
                values: ['2012'],
            }
        }
    },
    columnVisibility: {
        hiddenColIds: ['athlete'],
    },
    rowGroup: {
        groupColIds: ['athlete'],
    }
};

The current grid state can be retrieved by listening to the state updated event, which is fired with the latest state when it changes, or via api.getState().

The state is also passed in the Grid Pre-Destroyed Event, which can be used to get the state when the grid is destroyed.