Skip to content

Commit ea4d40a

Browse files
authoredMar 10, 2024
chore: split column and row pinning (#5402)
1 parent 16d16dd commit ea4d40a

File tree

13 files changed

+706
-643
lines changed

13 files changed

+706
-643
lines changed
 

‎docs/api/features/column-pinning.md

+266
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,266 @@
1+
---
2+
title: Column Pinning APIs
3+
id: column-pinning
4+
---
5+
6+
## Can-Pin
7+
8+
The ability for a column to be **pinned** is determined by the following:
9+
10+
- `options.enablePinning` is not set to `false`
11+
- `options.enableColumnPinning` is not set to `false`
12+
- `columnDefinition.enablePinning` is not set to `false`
13+
14+
## State
15+
16+
Pinning state is stored on the table using the following shape:
17+
18+
```tsx
19+
export type ColumnPinningPosition = false | 'left' | 'right'
20+
21+
export type ColumnPinningState = {
22+
left?: string[]
23+
right?: string[]
24+
}
25+
26+
27+
export type ColumnPinningTableState = {
28+
columnPinning: ColumnPinningState
29+
}
30+
```
31+
32+
## Table Options
33+
34+
### `enableColumnPinning`
35+
36+
```tsx
37+
enableColumnPinning?: boolean
38+
```
39+
40+
Enables/disables column pinning for all columns in the table.
41+
42+
### `onColumnPinningChange`
43+
44+
```tsx
45+
onColumnPinningChange?: OnChangeFn<ColumnPinningState>
46+
```
47+
48+
If provided, this function will be called with an `updaterFn` when `state.columnPinning` changes. This overrides the default internal state management, so you will also need to supply `state.columnPinning` from your own managed state.
49+
50+
## Column Def Options
51+
52+
### `enablePinning`
53+
54+
```tsx
55+
enablePinning?: boolean
56+
```
57+
58+
Enables/disables pinning for the column.
59+
60+
## Table API
61+
62+
### `setColumnPinning`
63+
64+
```tsx
65+
setColumnPinning: (updater: Updater<ColumnPinningState>) => void
66+
```
67+
68+
Sets or updates the `state.columnPinning` state.
69+
70+
### `resetColumnPinning`
71+
72+
```tsx
73+
resetColumnPinning: (defaultState?: boolean) => void
74+
```
75+
76+
Resets the **columnPinning** state to `initialState.columnPinning`, or `true` can be passed to force a default blank state reset to `{ left: [], right: [], }`.
77+
78+
### `getIsSomeColumnsPinned`
79+
80+
```tsx
81+
getIsSomeColumnsPinned: (position?: ColumnPinningPosition) => boolean
82+
```
83+
84+
Returns whether or not any columns are pinned. Optionally specify to only check for pinned columns in either the `left` or `right` position.
85+
86+
_Note: Does not account for column visibility_
87+
88+
### `getLeftHeaderGroups`
89+
90+
```tsx
91+
getLeftHeaderGroups: () => HeaderGroup<TData>[]
92+
```
93+
94+
Returns the left pinned header groups for the table.
95+
96+
### `getCenterHeaderGroups`
97+
98+
```tsx
99+
getCenterHeaderGroups: () => HeaderGroup<TData>[]
100+
```
101+
102+
Returns the unpinned/center header groups for the table.
103+
104+
### `getRightHeaderGroups`
105+
106+
```tsx
107+
getRightHeaderGroups: () => HeaderGroup<TData>[]
108+
```
109+
110+
Returns the right pinned header groups for the table.
111+
112+
### `getLeftFooterGroups`
113+
114+
```tsx
115+
getLeftFooterGroups: () => HeaderGroup<TData>[]
116+
```
117+
118+
Returns the left pinned footer groups for the table.
119+
120+
### `getCenterFooterGroups`
121+
122+
```tsx
123+
getCenterFooterGroups: () => HeaderGroup<TData>[]
124+
```
125+
126+
Returns the unpinned/center footer groups for the table.
127+
128+
### `getRightFooterGroups`
129+
130+
```tsx
131+
getRightFooterGroups: () => HeaderGroup<TData>[]
132+
```
133+
134+
Returns the right pinned footer groups for the table.
135+
136+
### `getLeftFlatHeaders`
137+
138+
```tsx
139+
getLeftFlatHeaders: () => Header<TData>[]
140+
```
141+
142+
Returns a flat array of left pinned headers for the table, including parent headers.
143+
144+
### `getCenterFlatHeaders`
145+
146+
```tsx
147+
getCenterFlatHeaders: () => Header<TData>[]
148+
```
149+
150+
Returns a flat array of unpinned/center headers for the table, including parent headers.
151+
152+
### `getRightFlatHeaders`
153+
154+
```tsx
155+
getRightFlatHeaders: () => Header<TData>[]
156+
```
157+
158+
Returns a flat array of right pinned headers for the table, including parent headers.
159+
160+
### `getLeftLeafHeaders`
161+
162+
```tsx
163+
getLeftLeafHeaders: () => Header<TData>[]
164+
```
165+
166+
Returns a flat array of leaf-node left pinned headers for the table.
167+
168+
### `getCenterLeafHeaders`
169+
170+
```tsx
171+
getCenterLeafHeaders: () => Header<TData>[]
172+
```
173+
174+
Returns a flat array of leaf-node unpinned/center headers for the table.
175+
176+
### `getRightLeafHeaders`
177+
178+
```tsx
179+
getRightLeafHeaders: () => Header<TData>[]
180+
```
181+
182+
Returns a flat array of leaf-node right pinned headers for the table.
183+
184+
### `getLeftLeafColumns`
185+
186+
```tsx
187+
getLeftLeafColumns: () => Column<TData>[]
188+
```
189+
190+
Returns all left pinned leaf columns.
191+
192+
### `getRightLeafColumns`
193+
194+
```tsx
195+
getRightLeafColumns: () => Column<TData>[]
196+
```
197+
198+
Returns all right pinned leaf columns.
199+
200+
### `getCenterLeafColumns`
201+
202+
```tsx
203+
getCenterLeafColumns: () => Column<TData>[]
204+
```
205+
206+
Returns all center pinned (unpinned) leaf columns.
207+
208+
## Column API
209+
210+
### `getCanPin`
211+
212+
```tsx
213+
getCanPin: () => boolean
214+
```
215+
216+
Returns whether or not the column can be pinned.
217+
218+
### `getPinnedIndex`
219+
220+
```tsx
221+
getPinnedIndex: () => number
222+
```
223+
224+
Returns the numeric pinned index of the column within a pinned column group.
225+
226+
### `getIsPinned`
227+
228+
```tsx
229+
getIsPinned: () => ColumnPinningPosition
230+
```
231+
232+
Returns the pinned position of the column. (`'left'`, `'right'` or `false`)
233+
234+
### `pin`
235+
236+
```tsx
237+
pin: (position: ColumnPinningPosition) => void
238+
```
239+
240+
Pins a column to the `'left'` or `'right'`, or unpins the column to the center if `false` is passed.
241+
242+
## Row API
243+
244+
### `getLeftVisibleCells`
245+
246+
```tsx
247+
getLeftVisibleCells: () => Cell<TData>[]
248+
```
249+
250+
Returns all left pinned leaf cells in the row.
251+
252+
### `getRightVisibleCells`
253+
254+
```tsx
255+
getRightVisibleCells: () => Cell<TData>[]
256+
```
257+
258+
Returns all right pinned leaf cells in the row.
259+
260+
### `getCenterVisibleCells`
261+
262+
```tsx
263+
getCenterVisibleCells: () => Cell<TData>[]
264+
```
265+
266+
Returns all center pinned (unpinned) leaf cells in the row.

0 commit comments

Comments
 (0)
Please sign in to comment.