Skip to content

Commit 801ee96

Browse files
authoredJan 15, 2024
docs: Row model docs (#5276)
* start * basic row model docs
1 parent 3afe02d commit 801ee96

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed
 

‎docs/guide/column-defs.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ title: Columns
66

77
[Table API](../api/core/table)
88

9-
## Guide
9+
## Column Definitions Guide
1010

1111
Column defs are the single most important part of building a table. They are responsible for:
1212

‎docs/guide/row-models.md

+57-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,59 @@
11
---
22
title: Row Models
3-
---
3+
---
4+
5+
## Row Models Guide
6+
7+
If you take a look at the most basic example of TanStack Table, you'll see a code snippet like this:
8+
9+
```ts
10+
import { getCoreRowModel, useReactTable } from '@tanstack/react-table'
11+
12+
function Component() {
13+
const table = useReactTable({
14+
data,
15+
columns,
16+
getCoreRowModel: getCoreRowModel(), //row model
17+
})
18+
}
19+
```
20+
21+
What is this `getCoreRowModel` function? And why do you have to import it from TanStack Table only to just pass it back to itself?
22+
23+
Well the answer is that TanStack Table is a modular library. Not all code for every single feature is included in the createTable functions/hooks by default. You only need to import and include the code that you will need to correctly generate rows based on the features you want to use.
24+
25+
### Import Row Models
26+
27+
You should only import the row models that you need. Here are all of the row models that are available:
28+
29+
```ts
30+
import {
31+
getCoreRowModel,
32+
getExpandedRowModel,
33+
getFacetedMinMaxValues,
34+
getFacetedRowModel,
35+
getFacetedUniqueValues,
36+
getFilteredRowModel,
37+
getGroupedRowModel,
38+
getPaginationRowModel,
39+
getSortedRowModel,
40+
}
41+
//...
42+
const table = useReactTable({
43+
data,
44+
columns,
45+
getCoreRowModel: getCoreRowModel(),
46+
getExpandedRowModel: getExpandedRowModel(),
47+
getFacetedMinMaxValues: getFacetedMinMaxValues(),
48+
getFacetedRowModel: getFacetedRowModel(),
49+
getFacetedUniqueValues: getFacetedUniqueValues(),
50+
getFilteredRowModel: getFilteredRowModel(),
51+
getGroupedRowModel: getGroupedRowModel(),
52+
getPaginationRowModel: getPaginationRowModel(),
53+
getSortedRowModel: getSortedRowModel(),
54+
})
55+
```
56+
57+
### Customize/Fork Row Models
58+
59+
You don't have to use the exact row models that are provided by TanStack Table. If you need some advanced customization for certain row models, feel free to copy the [source code](https://github.com/TanStack/table/tree/main/packages/table-core/src/utils) for the row model you want to customize and modify it to your needs.

0 commit comments

Comments
 (0)
Please sign in to comment.