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

Function getFacetedRowModel

packages/table-core/src/utils/getFacetedRowModel.ts:5–44  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import { filterRows } from './filterRowsUtils'
4
5export function getFacetedRowModel<TData extends RowData>(): (
6 table: Table<TData>,
7 columnId: string
8) => () => RowModel<TData> {
9 return (table, columnId) =>
10 memo(
11 () => [
12 table.getPreFilteredRowModel(),
13 table.getState().columnFilters,
14 table.getState().globalFilter,
15 table.getFilteredRowModel(),
16 ],
17 (preRowModel, columnFilters, globalFilter) => {
18 if (
19 !preRowModel.rows.length ||
20 (!columnFilters?.length && !globalFilter)
21 ) {
22 return preRowModel
23 }
24
25 const filterableIds = [
26 ...columnFilters.map(d => d.id).filter(d => d !== columnId),
27 globalFilter ? '__global__' : undefined,
28 ].filter(Boolean) as string[]
29
30 const filterRowsImpl = (row: Row<TData>) => {
31 // Horizontally filter rows through each column
32 for (let i = 0; i < filterableIds.length; i++) {
33 if (row.columnFilters[filterableIds[i]!] === false) {
34 return false
35 }
36 }
37 return true
38 }
39
40 return filterRows(preRowModel.rows, filterRowsImpl, table)
41 },
42 getMemoOptions(table.options, 'debugTable', 'getFacetedRowModel')
43 )
44}

Callers 5

AppFunction · 0.85
AppFunction · 0.85
main.tsxFile · 0.85
AppComponentClass · 0.85
AppFunction · 0.85

Calls 3

memoFunction · 0.90
filterRowsFunction · 0.90
getMemoOptionsFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…