Reputation: 1995
I have built this grid using ag-grid:
I want to know when the user clicks on a specific cell the following:
- RowId
- ColumnId (The field attribute in the columns definitions)
So far I have only managed to collect the rowId this way:
Relevant html code:
(rowClicked)="getRowId($event)"
Relevant TypeScript code:
getRowId(chosenRow) {
console.log('chosenRow.node: ', chosenRow.node);
}
I am wondering if I can use a similar approach to detect which column the user has just selected?
Thank you!
Upvotes: 1
Views: 2311
Reputation: 749
You can achieve this by simply listening to the grid cell clicked event as below.
this.gridOptions.onCellClicked = ((event: CellClickedEvent) => {
const rowId = event.rowIndex;
const colId = event.column.colId;
});
Upvotes: 2
Reputation: 1995
(cellClicked)="updateDepartementsDropDownList($event);"
typescript :
updateDepartementsDropDownList(params) {
const colId = params.column.getId();
console.log('colId: ', colId);
}
Upvotes: 0