Skip to content

Commit

Permalink
default keepPinnedRows to true
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinVandy committed Sep 16, 2023
1 parent 3a453c2 commit bb350ad
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 34 deletions.
51 changes: 29 additions & 22 deletions docs/api/features/pinning.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,14 @@ enableRowPinning?: boolean | ((row: Row<TData>) => boolean)
Enables/disables row pinning for all rows in the table.
### `keepPinnedRows`
```tsx
keepPinnedRows?: boolean
```
When `false`, pinned rows will not be visible if they are filtered or paginated out of the table. When `true`, pinned rows will always be visible regardless of filtering or pagination. Defaults to `true`.
### `onColumnPinningChange`
```tsx
Expand Down Expand Up @@ -148,143 +156,143 @@ Returns whether or not any rows are pinned. Optionally specify to only check for
### `getLeftHeaderGroups`
```tsx
getLeftHeaderGroups: () => HeaderGroup<TData>[]
getLeftHeaderGroups: () => HeaderGroup < TData > []
```
Returns the left pinned header groups for the table.
### `getCenterHeaderGroups`
```tsx
getCenterHeaderGroups: () => HeaderGroup<TData>[]
getCenterHeaderGroups: () => HeaderGroup < TData > []
```
Returns the unpinned/center header groups for the table.
### `getRightHeaderGroups`
```tsx
getRightHeaderGroups: () => HeaderGroup<TData>[]
getRightHeaderGroups: () => HeaderGroup < TData > []
```
Returns the right pinned header groups for the table.
### `getLeftFooterGroups`
```tsx
getLeftFooterGroups: () => HeaderGroup<TData>[]
getLeftFooterGroups: () => HeaderGroup < TData > []
```
Returns the left pinned footer groups for the table.
### `getCenterFooterGroups`
```tsx
getCenterFooterGroups: () => HeaderGroup<TData>[]
getCenterFooterGroups: () => HeaderGroup < TData > []
```
Returns the unpinned/center footer groups for the table.
### `getRightFooterGroups`
```tsx
getRightFooterGroups: () => HeaderGroup<TData>[]
getRightFooterGroups: () => HeaderGroup < TData > []
```
Returns the right pinned footer groups for the table.
### `getLeftFlatHeaders`
```tsx
getLeftFlatHeaders: () => Header<TData>[]
getLeftFlatHeaders: () => Header < TData > []
```
Returns a flat array of left pinned headers for the table, including parent headers.
### `getCenterFlatHeaders`
```tsx
getCenterFlatHeaders: () => Header<TData>[]
getCenterFlatHeaders: () => Header < TData > []
```
Returns a flat array of unpinned/center headers for the table, including parent headers.
### `getRightFlatHeaders`
```tsx
getRightFlatHeaders: () => Header<TData>[]
getRightFlatHeaders: () => Header < TData > []
```
Returns a flat array of right pinned headers for the table, including parent headers.
### `getLeftLeafHeaders`
```tsx
getLeftLeafHeaders: () => Header<TData>[]
getLeftLeafHeaders: () => Header < TData > []
```
Returns a flat array of leaf-node left pinned headers for the table.
### `getCenterLeafHeaders`
```tsx
getCenterLeafHeaders: () => Header<TData>[]
getCenterLeafHeaders: () => Header < TData > []
```
Returns a flat array of leaf-node unpinned/center headers for the table.
### `getRightLeafHeaders`
```tsx
getRightLeafHeaders: () => Header<TData>[]
getRightLeafHeaders: () => Header < TData > []
```
Returns a flat array of leaf-node right pinned headers for the table.
### `getLeftLeafColumns`
```tsx
getLeftLeafColumns: () => Column<TData>[]
getLeftLeafColumns: () => Column < TData > []
```
Returns all left pinned leaf columns.
### `getRightLeafColumns`
```tsx
getRightLeafColumns: () => Column<TData>[]
getRightLeafColumns: () => Column < TData > []
```
Returns all right pinned leaf columns.
### `getCenterLeafColumns`
```tsx
getCenterLeafColumns: () => Column<TData>[]
getCenterLeafColumns: () => Column < TData > []
```
Returns all center pinned (unpinned) leaf columns.
### `getTopRows`
```tsx
getTopRows: () => Row<TData>[]
getTopRows: () => Row < TData > []
```
Returns all top pinned rows.
### `getBottomRows`
```tsx
getBottomRows: () => Row<TData>[]
getBottomRows: () => Row < TData > []
```
Returns all bottom pinned rows.
### `getCenterRows`
```tsx
getCenterRows: () => Row<TData>[]
getCenterRows: () => Row < TData > []
```
Returns all rows that are not pinned to the top or bottom.
Expand Down Expand Up @@ -360,24 +368,23 @@ Returns the numeric pinned index of the row within a pinned row group.
### `getLeftVisibleCells`
```tsx
getLeftVisibleCells: () => Cell<TData>[]
getLeftVisibleCells: () => Cell < TData > []
```
Returns all left pinned leaf cells in the row.
### `getRightVisibleCells`
```tsx
getRightVisibleCells: () => Cell<TData>[]
getRightVisibleCells: () => Cell < TData > []
```
Returns all right pinned leaf cells in the row.
### `getCenterVisibleCells`
```tsx
getCenterVisibleCells: () => Cell<TData>[]
getCenterVisibleCells: () => Cell < TData > []
```
Returns all center pinned (unpinned) leaf cells in the row.
2 changes: 1 addition & 1 deletion examples/react/row-pinning/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ function App() {
getExpandedRowModel: getExpandedRowModel(),
getPaginationRowModel: getPaginationRowModel(),
keepPinnedRows,
// debugRows: true,
debugRows: true,
})

return (
Expand Down
23 changes: 12 additions & 11 deletions packages/table-core/src/features/Pinning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,17 +398,18 @@ export const Pinning: TableFeature = {
memo(
() => [table.getRowModel().rows, table.getState().rowPinning[position]],
(visibleRows, pinnedRowIds) => {
const rows = table.options.keepPinnedRows
? //get all rows that are pinned even if they would not be otherwise visible
//account for expanded parent rows, but not pagination or filtering
(pinnedRowIds ?? []).map(rowId => {
const row = table.getRow(rowId, true)
return row.getIsAllParentsExpanded() ? row : null
})
: //else get only visible rows that are pinned
(pinnedRowIds ?? []).map(
rowId => visibleRows.find(row => row.id === rowId)!
)
const rows =
table.options.keepPinnedRows ?? true
? //get all rows that are pinned even if they would not be otherwise visible
//account for expanded parent rows, but not pagination or filtering
(pinnedRowIds ?? []).map(rowId => {
const row = table.getRow(rowId, true)
return row.getIsAllParentsExpanded() ? row : null
})
: //else get only visible rows that are pinned
(pinnedRowIds ?? []).map(
rowId => visibleRows.find(row => row.id === rowId)!
)

return rows
.filter(Boolean)
Expand Down

0 comments on commit bb350ad

Please sign in to comment.