ag-grid react 如何使用复选框处理数据
ag-grid react How to handle data with checkbox
我想在点击复选框时获取数据
我试过使用 onCellClicked
单击行
时,我收到有关 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 Row is selected or deselected.
我想在点击复选框时获取数据
我试过使用 onCellClicked 单击行
时,我收到有关 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 Row is selected or deselected.