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

Function App

examples/react/grouping/src/main.tsx:19–282  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17import { makeData, Person } from './makeData'
18
19function App() {
20 const rerender = React.useReducer(() => ({}), {})[1]
21
22 const columns = React.useMemo<ColumnDef<Person>[]>(
23 () => [
24 {
25 header: 'Name',
26 columns: [
27 {
28 accessorKey: 'firstName',
29 header: 'First Name',
30 cell: info => info.getValue(),
31 /**
32 * override the value used for row grouping
33 * (otherwise, defaults to the value derived from accessorKey / accessorFn)
34 */
35 getGroupingValue: row => `${row.firstName} ${row.lastName}`,
36 },
37 {
38 accessorFn: row => row.lastName,
39 id: 'lastName',
40 header: () => <span>Last Name</span>,
41 cell: info => info.getValue(),
42 },
43 ],
44 },
45 {
46 header: 'Info',
47 columns: [
48 {
49 accessorKey: 'age',
50 header: () => 'Age',
51 aggregatedCell: ({ getValue }) =>
52 Math.round(getValue<number>() * 100) / 100,
53 aggregationFn: 'median',
54 },
55 {
56 header: 'More Info',
57 columns: [
58 {
59 accessorKey: 'visits',
60 header: () => <span>Visits</span>,
61 aggregationFn: 'sum',
62 // aggregatedCell: ({ getValue }) => getValue().toLocaleString(),
63 },
64 {
65 accessorKey: 'status',
66 header: 'Status',
67 },
68 {
69 accessorKey: 'progress',
70 header: 'Profile Progress',
71 cell: ({ getValue }) =>
72 Math.round(getValue<number>() * 100) / 100 + '%',
73 aggregationFn: 'mean',
74 aggregatedCell: ({ getValue }) =>
75 Math.round(getValue<number>() * 100) / 100 + '%',
76 },

Callers

nothing calls this directly

Calls 13

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

Tested by

no test coverage detected