MCPcopy
hub / github.com/TanStack/table / Table

Function Table

examples/react/query-router-search-params/src/components/table.tsx:28–188  ·  view source on GitHub ↗
({
  data,
  columns,
  pagination,
  paginationOptions,
  filters,
  onFilterChange,
  sorting,
  onSortingChange,
}: Props<T>)

Source from the content-addressed store, hash-verified

26}
27
28export default function Table<T extends Record<string, string | number>>({
29 data,
30 columns,
31 pagination,
32 paginationOptions,
33 filters,
34 onFilterChange,
35 sorting,
36 onSortingChange,
37}: Props<T>) {
38 const table = useReactTable({
39 data,
40 columns,
41 state: { pagination, sorting },
42 onSortingChange,
43 ...paginationOptions,
44 manualFiltering: true,
45 manualSorting: true,
46 manualPagination: true,
47 getCoreRowModel: getCoreRowModel(),
48 })
49
50 return (
51 <div>
52 <table>
53 <thead>
54 {table.getHeaderGroups().map(headerGroup => (
55 <tr key={headerGroup.id}>
56 {headerGroup.headers.map(header => {
57 const fieldMeta = header.column.columnDef.meta
58 return (
59 <th key={header.id} colSpan={header.colSpan}>
60 {header.isPlaceholder ? null : (
61 <>
62 <div
63 {...{
64 className: header.column.getCanSort()
65 ? 'cursor-pointer select-none'
66 : '',
67 onClick: header.column.getToggleSortingHandler(),
68 }}
69 >
70 {flexRender(
71 header.column.columnDef.header,
72 header.getContext()
73 )}
74 {{
75 asc: ' 🔼',
76 desc: ' 🔽',
77 false: ' 🔃',
78 }[header.column.getIsSorted() as string] ?? null}
79 </div>
80 {header.column.getCanFilter() &&
81 fieldMeta?.filterKey !== undefined ? (
82 <DebouncedInput
83 className="w-36 border shadow rounded"
84 onChange={value => {
85 onFilterChange({

Callers

nothing calls this directly

Calls 6

useReactTableFunction · 0.90
flexRenderFunction · 0.90
getCoreRowModelFunction · 0.85
getContextMethod · 0.80
previousPageMethod · 0.80
nextPageMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…