row selection checkboxes as the last column
I wanted to know whether it's possible to get the row selection checkboxes as the last row.
2 Replies
other-emerald•15mo ago
add such column at the end of your columnDef array.
const columns = [
// other columns....,
{
id: 'select-col',
header: ({ table }) => (
<Checkbox
checked={table.getIsAllRowsSelected()}
indeterminate={table.getIsSomeRowsSelected()}
onChange={table.getToggleAllRowsSelectedHandler()} //or getToggleAllPageRowsSelectedHandler
/>
),
cell: ({ row }) => (
<Checkbox
checked={row.getIsSelected()}
disabled={!row.getCanSelect()}
onChange={row.getToggleSelectedHandler()}
/>
),
},
]
reference: https://tanstack.com/table/latest/docs/guide/row-selection
Row Selection Guide | TanStack Table Docs
Examples
Want to skip to the implementation? Check out these examples:
foreign-sapphire•15mo ago
The simple answer is yes, just define it as the last object in your columns array.