subman-nextjs/src/app/ui/tables/selectColumn.tsx

33 lines
897 B
TypeScript
Raw Normal View History

2024-06-30 11:36:13 +00:00
import { Checkbox } from "@/components/ui/checkbox";
import { CellContext, Column, ColumnDef, ColumnMeta, Header, HeaderContext, RowSelectionTableState, Table, TableState } from "@tanstack/react-table";
export const selectCol = {
id: "select",
header: (props: HeaderContext<any, any>) => {
return (
<div className="flex items-center justify-center">
<Checkbox
checked={props.table.getIsAllRowsSelected()}
onCheckedChange={props.table.toggleAllRowsSelected}
aria-label="select/deselect all rows"
/>
</div>
)
},
cell: (props: CellContext<any, any>) => {
return (
<div className="flex items-center justify-center">
<Checkbox
checked={props.row.getIsSelected()}
onCheckedChange={props.row.toggleSelected}
2024-06-30 18:28:02 +00:00
aria-label="select/deselect row"
/>
2024-06-30 11:36:13 +00:00
</div>
)
}
}