-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
There is space between adjacent pinned columns #5783
Comments
I'm facing the same issue. Also, have you tried adding the CSS hover property to make it work across the entire row? For some reason, I can't get it to work. |
@pintuiitbhi Please make sure your formatted code renders properly in the issue description, it's currently very hard to read. From what I understand the default column size is 150px if you don't give the column a size, the 2 issues here:
Any thoughts? |
@ThomasBnf I'm also using ShadCN, what I do is set the checkbox column def size exactly the same as the size of the checkbox cell, in my case export const checkboxColumn = columnHelper.display({
id: 'select',
size: 32,
header: ({ table }) => (
<Checkbox
checked={
table.getIsAllPageRowsSelected() ||
(table.getIsSomePageRowsSelected() && 'indeterminate')
}
onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}
aria-label="Select all"
/>
),
cell: ({ row }) => (
<Checkbox
checked={row.getIsSelected()}
onCheckedChange={(value) => row.toggleSelected(!!value)}
aria-label="Select row"
/>
),
enableSorting: false,
enableHiding: false,
}); Otherwise if I don't set it to |
I still have the gap when I put 32px. I tried less, and 26px is working, no more gap |
@ThomasBnf That's why I said you have to measure the size of your cell with devtools. |
Setting a Fixed Column WidthYou can use the {
accessorKey: "state",
id: "state",
header: "State",
size: 150, // Sets a fixed width in pixels
cell: (info) => (
<div style={{ width: "150px", overflow: "hidden", textOverflow: "ellipsis" }}>
{info.getValue() || "-"}
</div>
),
}, |
TanStack Table version
v8.13.2
Framework/Library version
React 18
Describe the bug and the steps to reproduce it
There is space between the first two pinned column.
This is the common pinning style code
`import { Column } from "@tanstack/react-table"
import { ListingType } from "./columns"
import { CSSProperties } from "react"
export const getCommonPinningStyles = (column: Column): CSSProperties => {
const isPinned = column.getIsPinned()
const isLastLeftPinnedColumn =
isPinned === 'left' && column.getIsLastColumn('left')
const isFirstRightPinnedColumn =
isPinned === 'right' && column.getIsFirstColumn('right')
}
`
This is column def
{ id: "select", header: ({ table }) => ( <IndeterminateCheckbox checked={table.getIsAllRowsSelected()} indeterminate={table.getIsSomeRowsSelected()} onChange={table.getToggleAllRowsSelectedHandler()} /> ), cell: ({ row }) => ( <IndeterminateCheckbox checked={row.getIsSelected()} disabled={!row.getCanSelect()} indeterminate={row.getIsSomeSelected()} onChange={row.getToggleSelectedHandler()} /> ), enableSorting: false, enableHiding: false, }, { accessorKey: "state", id: "state", header: "State", cell: (info) => info.getValue() || "-", },
This is table defintion
const table: TanstackTable<TData> = useReactTable({ data, columns: columns as any, // @TODO: fix typescript defaultColumn: { size: 100, //starting column size // minSize: 50, //enforced during column resizing // maxSize: 200, //enforced during column resizing }, onRowSelectionChange: setRowSelection, pageCount: pageCount ?? -1, enableRowSelection: true, getCoreRowModel: getCoreRowModel(), getFilteredRowModel: getFilteredRowModel(), onSortingChange: setSorting, onColumnFiltersChange: setColumnFilters, onColumnVisibilityChange: setColumnVisibility, getSortedRowModel: getSortedRowModel(), state: { pagination: { pageIndex, pageSize }, rowSelection, sorting, columnVisibility, columnFilters, }, initialState: { columnPinning: { left: ['select', 'state'], right: ['status', 'actions'], }, }, columnResizeMode: 'onChange', onPaginationChange: setPagination, getPaginationRowModel: getPaginationRowModel(), manualPagination: true, manualFiltering: true, meta: { // removeRow: (rowIndex: number) => { // deleteRow(data[rowIndex].id); // }, // removeSelectedRows: (selectedRows: number[]) => { // selectedRows.forEach((rowIndex) => { // deleteRow(data[rowIndex].id); // }); // }, } });
This is css for table
table {
border-collapse: separate;
border-spacing: 0;
}
th {
border: 0.5px solid #f2f2f2;
font-weight: bold;
text-transform: uppercase;
background-color: white;
}
td {
background-color: white;
border: 0.5px solid #f2f2f2;
}
Your Minimal, Reproducible Example - (Sandbox Highly Recommended)
NA
Screenshots or Videos (Optional)
No response
Do you intend to try to help solve this bug with your own PR?
None
Terms & Code of Conduct
The text was updated successfully, but these errors were encountered: