Skip to content
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

Row Pinning feature, example, and docs #5074

Merged
merged 6 commits into from
Sep 17, 2023
Merged

Row Pinning feature, example, and docs #5074

merged 6 commits into from
Sep 17, 2023

Conversation

KevinVandy
Copy link
Member

@KevinVandy KevinVandy commented Sep 16, 2023

This PR adds Row Pinning functionality to TanStack Table, in addition to the column pinning functionality already present.

Most changes to table-core are confined to Pinning.ts, with a couple more tweaks to solve edge cases needed in Expanding.ts and table.ts
 
New Table State:

rowPinning: { top?: string[], bottom?: string[] }

New Table Options:

enableColumnPinning?: boolean //distinguish from `enablePinning` (still backwards compat)
onRowPinningChange?: OnChangeFn<RowPinningState>
enableRowPinning?: boolean | ((row: Row<TData>) => boolean)
keepPinnedRows?: boolean

New Table APIs:

setRowPinning: (updater: Updater<RowPinningState>) => void
resetRowPinning: (defaultState?: boolean) => void
getIsSomeRowsPinned: (position?: RowPinningPosition) => boolean
_getPinnedRows: (position: 'top' | 'bottom') => Row<TData>[]
getTopRows: () => Row<TData>[]
getBottomRows: () => Row<TData>[]
getCenterRows: () => Row<TData>[]

New Row APIs:

getCanPin: () => boolean
getIsPinned: () => RowPinningPosition
getPinnedIndex: () => number
pin: (
  position: RowPinningPosition,
  includeLeafRows?: boolean,
  includeParentRows?: boolean
) => void
getIsAllParentsExpanded: () => boolean

Caveats

table.getRow was tweaked to allow for finding rows from table.getCoreRowModel() instead of the default table.getRowModel

The compiled size of TanStack Table Core increases from 13.9 kb to 14.3 kb

image

@tannerlinsley
Copy link
Collaborator

Seems useful and a core concern. I’m good to include it.

@KevinVandy KevinVandy merged commit 15a425a into TanStack:main Sep 17, 2023
1 check passed
@KevinVandy KevinVandy mentioned this pull request Sep 18, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants