If a user click or select a row in ag-grid then I want to fire a click event. I searched the doc but no luck.
Asked
Active
Viewed 1.1k times
1 Answers
3
It's called onRowClicked
and onRowSelected
respectively. onRowClicked
will be called when you click a row even if you disable row selection. onRowSelected
on the other hand only fires when a row is selected
<AgGridReact
columnDefs={columnDefs}
onRowSelected={(e) => console.log("row selected", e.rowIndex)}
onRowClicked={(e) => console.log("row clicked", e.rowIndex)}
rowSelection="multiple"
rowData={rowData}
/>
Another way is to catch all of the ag-grid events using GridApi.addGlobalListener()
and filter out the ones you're not interested in.
const onGridReady = (params: GridReadyEvent) => {
params.api.addGlobalListener((type: string, e) => {
if (type === "rowClicked" || type === "rowSelected") {
console.log(type, "from global event handler");
}
});
};
Live Demo

NearHuscarl
- 66,950
- 18
- 261
- 230