我想停止所有单元格点击的事件传播,因为我正在使用onRowClicked
执行一些操作。当用户单击单元格内的某些内容(例如输入字段)时,我不希望触发行单击。
有什么想法吗?
我为此使用 Angular 2/4。
我想停止所有单元格点击的事件传播,因为我正在使用onRowClicked
执行一些操作。当用户单击单元格内的某些内容(例如输入字段)时,我不希望触发行单击。
有什么想法吗?
我为此使用 Angular 2/4。
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
}
}
<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"
防止行单击