Ag grid 如何在ag网格中检索所选列的Id?

Ag grid 如何在ag网格中检索所选列的Id?,ag-grid,Ag Grid,我使用ag grid构建了这个网格: 我想知道用户何时单击特定单元格,如下所示: -RowId -ColumnId(列定义中的字段属性) 到目前为止,我仅通过以下方式收集rowId: 相关html代码: 相关类型脚本代码: 我想知道是否可以使用类似的方法来检测用户刚刚选择的列? 谢谢大家! (cellClicked)="updateDepartementsDropDownList($event);" 打字稿: updateDepartementsDropDownList(params)

我使用ag grid构建了这个网格:

我想知道用户何时单击特定单元格,如下所示:
-RowId
-ColumnId(列定义中的字段属性)

到目前为止,我仅通过以下方式收集rowId:

相关html代码:

相关类型脚本代码:

我想知道是否可以使用类似的方法来检测用户刚刚选择的列?
谢谢大家!

  (cellClicked)="updateDepartementsDropDownList($event);"
打字稿:

 updateDepartementsDropDownList(params) {
    const colId = params.column.getId();
    console.log('colId: ', colId);

  }

您可以通过如下简单地监听网格单元格单击事件来实现这一点

 this.gridOptions.onCellClicked = ((event: CellClickedEvent) => {
     const rowId = event.rowIndex;
     const colId = event.column.colId;
 });
 updateDepartementsDropDownList(params) {
    const colId = params.column.getId();
    console.log('colId: ', colId);

  }
 this.gridOptions.onCellClicked = ((event: CellClickedEvent) => {
     const rowId = event.rowIndex;
     const colId = event.column.colId;
 });