8

我想停止所有单元格点击的事件传播,因为我正在使用onRowClicked执行一些操作。当用户单击单元格内的某些内容(例如输入字段)时,我不希望触发行单击。

有什么想法吗?

我为此使用 Angular 2/4。

4

2 回答 2

8

None of the past suggestions worked for me. AG Grid may have changed the API behavior. Even event.stopPropagation() on onCellClicked would not stop onRowClicked from firing.

What I ultimately did was to remove onRowClicked altogether and handle everything in onCellClicked. onRowClicked does not have an attribute on which column the click event generated from, onCellClicked does!

function cellClickedHandler(e) {
  if (e.column.colId === 'col1') {
    // Handle specific cell
  } else {
    // Handle all other cells, similar to rowClicked
  }
}
于 2020-06-02T12:46:38.467 回答
5
  <ag-grid-angular style="width: 100%;   height: 168px;" class="ag-theme-fresh" 
    [rowData]="rowData" [columnDefs]="columnDefs"
    [enableFilter]="true" [enableSorting]="true" 
    [getRowNodeId]="getRowNodeId" [rowSelection]="rowSelection" 
    (selectionChanged)="onSelectionChanged($event)"
    (gridReady)="onGridReady($event)" 
    [suppressRowClickSelection]="true"
    (cellClicked)='onCellClicked($event)'>
  </ag-grid-angular>

用于 [suppressRowClickSelection]="true"防止行单击

于 2018-02-23T11:22:25.907 回答