MCPcopy Index your code
hub / github.com/TanStack/table / App

Function App

examples/react/row-pinning/src/main.tsx:23–345  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21} from '@tanstack/react-table'
22
23function App() {
24 const rerender = React.useReducer(() => ({}), {})[1]
25
26 //table states
27 const [rowPinning, setRowPinning] = React.useState<RowPinningState>({
28 top: [],
29 bottom: [],
30 })
31 const [expanded, setExpanded] = React.useState<ExpandedState>({})
32
33 //demo states
34 const [keepPinnedRows, setKeepPinnedRows] = React.useState(true)
35 const [includeLeafRows, setIncludeLeafRows] = React.useState(true)
36 const [includeParentRows, setIncludeParentRows] = React.useState(false)
37 const [copyPinnedRows, setCopyPinnedRows] = React.useState(false)
38
39 const columns = React.useMemo<ColumnDef<Person>[]>(
40 () => [
41 {
42 id: 'pin',
43 header: () => 'Pin',
44 cell: ({ row }) =>
45 row.getIsPinned() ? (
46 <button
47 onClick={() => row.pin(false, includeLeafRows, includeParentRows)}
48 >
49
50 </button>
51 ) : (
52 <div style={{ display: 'flex', gap: '4px' }}>
53 <button
54 onClick={() =>
55 row.pin('top', includeLeafRows, includeParentRows)
56 }
57 >
58 ⬆️
59 </button>
60 <button
61 onClick={() =>
62 row.pin('bottom', includeLeafRows, includeParentRows)
63 }
64 >
65 ⬇️
66 </button>
67 </div>
68 ),
69 },
70 {
71 accessorKey: 'firstName',
72 header: ({ table }) => (
73 <>
74 <button
75 {...{
76 onClick: table.getToggleAllRowsExpandedHandler(),
77 }}
78 >
79 {table.getIsAllRowsExpanded() ? '👇' : '👉'}
80 </button>{' '}

Callers

nothing calls this directly

Calls 12

makeDataFunction · 0.90
useReactTableFunction · 0.90
flexRenderFunction · 0.90
getCoreRowModelFunction · 0.85
getFilteredRowModelFunction · 0.85
getExpandedRowModelFunction · 0.85
getPaginationRowModelFunction · 0.85
getContextMethod · 0.80
previousPageMethod · 0.80
nextPageMethod · 0.80
refreshDataFunction · 0.70
rerenderFunction · 0.50

Tested by

no test coverage detected