我正在使用单选按钮来选择行。如何禁用多行选择,以便一次只能选择一行?
我正在使用 selectedFlatRows
,但它允许多行选择。
const Table = props => {
const {
getTableProps,
getTableBodyProps,
headerGroups,
page,
prepareRow,
selectedFlatRows,
} = useTable(
{
columns,
data: props.linkedProducts,
},
useSortBy,
usePagination,
useRowSelect,
hooks => {
hooks.visibleColumns.push(columns => [
{
id: 'selection',
disableGlobalFilter: true,
accessor: 'selection',
Cell: ({row}) => (
<RadioButton
{...row.getToggleRowSelectedProps()}
/>
),
},
...columns,
]);
}
);