addEventListener method on the Grid API or by providing event handlers in GridOptions.
Overview
There are two ways to listen to events:Via Grid API
Via GridOptions
Lifecycle Events
Called once when the grid is ready to use. Use this to access the Grid API.Event Properties:
api: Grid API referencecontext: Grid context object
Fired before the grid is destroyed. Useful for cleanup operations.Event Properties:
api: Grid API referencestate: Current state of the grid
The grid’s div was resized. Use this to resize columns or adjust layout.Event Properties:
clientWidth: The grid’s DIV’s clientWidthclientHeight: The grid’s DIV’s clientHeight
Fired the first time data is rendered into the grid. Use this event if you want to auto resize columns based on their contents.Event Properties:
firstRow: Index of the first rendered rowlastRow: Index of the last rendered row
Data Events
Fired when row data is updated via
api.setRowData() or the rowData property is changed.Fired after the row model (all rows) has been updated. This includes after sorting, filtering, grouping, etc.Event Properties:
animate: If true, the grid will try and animate the rows to the new positionskeepRenderedRows: If true, same data but sorted or filterednewData: If true, this update was a result of setRowData() getting callednewPage: True when pagination and a new page is navigated to
Fired when pinned row data is changed via the
pinnedTopRowData or pinnedBottomRowData properties.Selection Events
Fired when row selection is changed. Use the grid API to get the selected rows.Event Properties:
source: The source that triggered the selection change eventselectedNodes: The row nodes that are selected (ornullfor SSRM)serverSideState: The SSRM selection state (ornullfor other row models)
'api': from API method'checkboxSelected': row selection checkbox clicked'rowClicked': row clicked when row selection enabled'uiSelectAll': select all in header clicked'spaceKey': space key pressed on row
Fired when a row is selected or deselected.Event Properties:
node: The row nodedata: The row datarowIndex: The visible row indexsource: The source that triggered the event
Filtering Events
Fired when a filter is changed.Event Properties:
source: The source that triggered the filter change ('api','quickFilter','columnFilter','advancedFilter')afterDataChange: True if the filter was changed as a result of data changingafterFloatingFilter: True if filter was changed via floating filtercolumns: Columns affected by the filter change
Fired when the filter UI is modified but not yet applied (e.g., when using filter buttons).Event Properties:
filterInstance: The filter component instancecolumn: The column
Fired when a column filter is opened.Event Properties:
column: Column / ProvidedColumnGroup that contains the filtersource: Source of the open requesteGui: Parent element of the filter
Sorting Events
Fired when sorting is changed.Event Properties:
source: String describing where the event is coming fromcolumns: The list of columns impacted by the sort change
Pagination Events
Fired when the pagination state changes.Event Properties:
animate: True if rows were animated to new positionkeepRenderedRows: True if rows were kept (otherwise complete redraw)newData: True if data was newnewPage: True if user went to a new pagenewPageSize: True if user changed the page size
Viewport Events
Fired when the displayed rows have changed due to scrolling.Event Properties:
firstRow: Index of the first rendered rowlastRow: Index of the last rendered row
Fired when the grid’s body is scrolled horizontally or vertically.Event Properties:
direction: ScrollDirection (‘horizontal’ or ‘vertical’)left: Horizontal scroll positiontop: Vertical scroll position
Fired when the grid’s body has stopped scrolling.Event Properties:
direction: ScrollDirectionleft: Horizontal scroll positiontop: Vertical scroll position
State Events
Fired when the grid state has been updated.Event Properties:
state: The updated grid statesources: The state keys that triggered the update
GridStateModuleDrag Events
Fired when a drag operation has started (column, row, etc.).Event Properties:
target: The DOM element that started the event
Fired when a drag operation has finished.Event Properties:
target: The DOM element that started the event
Related APIs
Row Events
Events fired by row interactions
Column Events
Events fired by column interactions
GridApi
Add and remove event listeners programmatically