Single row selection not working
I've been trying to implement single row selection using the v8 of the table, but I'm unable to do so. I'm using radio buttons which ideally should allow me to select a single row, but I'm able to select to multiple rows.
I've tried various solutions but none of them seem to work. Can someone please help me with it
1 Reply
graceful-beige•3y ago
You Should try to use check box with this, if you're trying to select multiple rows one at a time.
This is the checkbox code for the header:
<Checkbox
checked={table.getIsAllPageRowsSelected()}
onCheckedChange={(value: unknown) =>
table.toggleAllPageRowsSelected(!!value)
}
aria-label="Select all"
className="translate-y-[2px]"
/>
This is the checkbox code for the cells in each row:
<Checkbox
checked={row.getIsSelected()}
onCheckedChange={(value: unknown) =>
row.toggleSelected(!!value)
}
aria-label="Select row"
className="translate-y-[2px]"
/>