Reputation: 2228
I am testing ag-grid and trying to get a row id when clicking on a row. I can see the value, but not retrieve it.
There is no clue in the documentation. Any tip how to retrieve the data?
Upvotes: 0
Views: 1377
Reputation: 907
From the ag-grid website can you use the selectionChanged event, find the selected rows and from there you can access the associated data?
<ag-grid-angular>
(selectionChanged)="onSelectionChanged($event)"
</ag-grid-angular>
onSelectionChanged() {
const selectedRows = this.gridApi.getSelectedRows();
const selectedId = selectedRows[0].id;
}
See this example: https://plnkr.co/edit/lfjvlLlbyixDOo6m
I've just reread your question and I didn't see you want to use rowClicked. Try this example: https://plnkr.co/edit/lfjvlLlbyixDOo6m
onRowClicked(params)
{
console.log(params)
const clickedItem = <dataItem>params.data;
console.log(clickedItem.athlete)
}
ie cast the item appropriately before using it.
Upvotes: 1