![](/img/trans.png)
[英]how to apply selectAll and deSelectAll to the header checkbox in ag-grid react
[英]ag-grid react How to handle data with checkbox
我想在单击复选框时获取数据
我试过使用 onCellClicked 我在单击行时收到 function onCellClick 上的数据
但是当我点击复选框时什么都没有
我应该使用哪些道具?
export const DataTable = ():JSX.Element=> {
...
const header = [
{
headerName: 'Select',
field: 'selectBox',
headerCheckboxSelection: true,
headerCheckboxSelectionFilteredOnly: true,
checkboxSelection: true
},
{
headerName: name,
field: 'name',
sortable: true,
filter: true
}
const onCellClick = (e: CellClickedEvent) => {
const data = e.data
}
return (
<AgGridReact
columnDefs={header}
onGridReady={onGridReady}
rowData={data}
rowSelection="mutiple"
animateRows={true}
suppressRowClickSelection={true}
rowMultiSelectWithClick={true}
onCellClicked={onCellClick}
/>
)
}
使用onRowSelected
而不是onCellClicked
。
根据文档: https://www.ag-grid.com/react-grid/grid-events/#reference-selection
rowSelected 行被选中或取消选中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.