Skip to content

Commit bc69a07

Browse files
committed
update examples to pass fns new way
1 parent c4191d7 commit bc69a07

File tree

55 files changed

+500
-343
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+500
-343
lines changed

docs/api/features/column-filtering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ Example:
356356
import { getFilteredRowModel } from '@tanstack/[adapter]-table'
357357

358358

359-
getFilteredRowModel: createFilteredRowModel(),
359+
getFilteredRowModel: createFilteredRowModel(filterFns),
360360
})
361361
```
362362

docs/api/features/global-filtering.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ Example:
196196
```tsx
197197
import { getFilteredRowModel } from '@tanstack/[adapter]-table'
198198

199-
getFilteredRowModel: createFilteredRowModel(),
199+
getFilteredRowModel: createFilteredRowModel(filterFns),
200200
})
201201
```
202202

docs/framework/lit/guide/table-state.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class MyComponent extends LitElement {
9090
this._sorting = updaterOrValue
9191
}
9292
},
93-
getSortedRowModel: createSortedRowModel(),
93+
getSortedRowModel: createSortedRowModel(sortFns),
9494
getCoreRowModel: createCoreRowModel(),
9595
})
9696

@@ -118,7 +118,7 @@ render() {
118118
columns,
119119
data,
120120
getCoreRowModel: createCoreRowModel(),
121-
getSortedRowModel: createSortedRowModel()
121+
getSortedRowModel: createSortedRowModel(sortFns)
122122
})
123123
const state = { ...table.initialState, ...this._tableState };
124124
table.setOptions(prev => ({
@@ -160,7 +160,7 @@ render() {
160160
this._sorting = updaterOrValue
161161
}
162162
},
163-
getSortedRowModel: createSortedRowModel(),
163+
getSortedRowModel: createSortedRowModel(sortFns),
164164
getCoreRowModel: createCoreRowModel(),
165165
})
166166

docs/guide/column-filtering.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ const table = useTable({
5454
data,
5555
columns,
5656
getCoreRowModel: createCoreRowModel(),
57-
// getFilteredRowModel: createFilteredRowModel(), // not needed for manual server-side filtering
57+
// getFilteredRowModel: createFilteredRowModel(filterFns), // not needed for manual server-side filtering
5858
manualFiltering: true,
5959
})
6060
```
@@ -72,7 +72,7 @@ const table = useTable({
7272
data,
7373
columns,
7474
getCoreRowModel: createCoreRowModel(),
75-
getFilteredRowModel: createFilteredRowModel(), // needed for client-side filtering
75+
getFilteredRowModel: createFilteredRowModel(filterFns), // needed for client-side filtering
7676
})
7777
```
7878

@@ -216,7 +216,7 @@ const table = useTable({
216216
columns,
217217
data,
218218
getCoreRowModel: createCoreRowModel(),
219-
getFilteredRowModel: createFilteredRowModel(),
219+
getFilteredRowModel: createFilteredRowModel(filterFns),
220220
filterFns: { // add a custom global filter function
221221
myCustomFilterFn: (row, columnId, filterValue) => { // defined inline here
222222
return // true or false based on your custom logic
@@ -296,7 +296,7 @@ const table = useTable({
296296
columns,
297297
data,
298298
getCoreRowModel: createCoreRowModel(),
299-
getFilteredRowModel: createFilteredRowModel(),
299+
getFilteredRowModel: createFilteredRowModel(filterFns),
300300
getExpandedRowModel: createExpandedRowModel(),
301301
filterFromLeafRows: true, // filter and search through sub-rows
302302
})
@@ -313,7 +313,7 @@ const table = useTable({
313313
columns,
314314
data,
315315
getCoreRowModel: createCoreRowModel(),
316-
getFilteredRowModel: createFilteredRowModel(),
316+
getFilteredRowModel: createFilteredRowModel(filterFns),
317317
getExpandedRowModel: createExpandedRowModel(),
318318
maxLeafRowFilterDepth: 0, // only filter root level parent rows out
319319
})

docs/guide/row-models.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ const table = useTable({
5252
getFacetedMinMaxValues: getFacetedMinMaxValues(),
5353
getFacetedRowModel: createFacetedRowModel(),
5454
getFacetedUniqueValues: getFacetedUniqueValues(),
55-
getFilteredRowModel: createFilteredRowModel(),
55+
getFilteredRowModel: createFilteredRowModel(filterFns),
5656
getGroupedRowModel: createGroupedRowModel(),
5757
getPaginatedRowModel: createPaginatedRowModel(),
58-
getSortedRowModel: createSortedRowModel(),
58+
getSortedRowModel: createSortedRowModel(sortFns),
5959
})
6060
```
6161

docs/guide/sorting.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ const table = useTable({
104104
columns,
105105
data,
106106
getCoreRowModel: createCoreRowModel(),
107-
//getSortedRowModel: createSortedRowModel(), //not needed for manual sorting
107+
//getSortedRowModel: createSortedRowModel(sortFns), //not needed for manual sorting
108108
manualSorting: true, //use pre-sorted row model instead of sorted row model
109109
state: {
110110
sorting,
@@ -126,7 +126,7 @@ const table = useTable({
126126
columns,
127127
data,
128128
getCoreRowModel: createCoreRowModel(),
129-
getSortedRowModel: createSortedRowModel(), //provide a sorting row model
129+
getSortedRowModel: createSortedRowModel(sortFns), //provide a sorting row model
130130
})
131131
```
132132

@@ -199,7 +199,7 @@ const table = useTable({
199199
columns,
200200
data,
201201
getCoreRowModel: createCoreRowModel(),
202-
getSortedRowModel: createSortedRowModel(),
202+
getSortedRowModel: createSortedRowModel(sortFns),
203203
sortFns: { //add a custom sorting function
204204
myCustomSortFn: (rowA, rowB, columnId) => {
205205
return rowA.original[columnId] > rowB.original[columnId] ? 1 : rowA.original[columnId] < rowB.original[columnId] ? -1 : 0

examples/angular/column-visibility/src/app/app.component.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import {
77
import {
88
FlexRenderDirective,
99
columnVisibilityFeature,
10-
createCoreRowModel,
1110
injectTable,
11+
isFunction,
1212
tableFeatures,
1313
} from '@tanstack/angular-table'
1414
import type { OnInit } from '@angular/core'
@@ -124,12 +124,10 @@ export class AppComponent implements OnInit {
124124
state: {
125125
columnVisibility: this.columnVisibility(),
126126
},
127-
getCoreRowModel: createCoreRowModel(),
128127
onColumnVisibilityChange: (updaterOrValue) => {
129-
const visibilityState =
130-
typeof updaterOrValue === 'function'
131-
? updaterOrValue(this.columnVisibility())
132-
: updaterOrValue
128+
const visibilityState = isFunction(updaterOrValue)
129+
? updaterOrValue(this.columnVisibility())
130+
: updaterOrValue
133131
this.columnVisibility.set(visibilityState)
134132
},
135133
debugTable: true,

examples/angular/filters/src/app/app.component.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ import {
88
FlexRenderDirective,
99
columnFacetingFeature,
1010
columnFilteringFeature,
11-
createCoreRowModel,
1211
createFacetedMinMaxValues,
1312
createFacetedRowModel,
1413
createFacetedUniqueValues,
1514
createFilteredRowModel,
1615
createPaginatedRowModel,
1716
createSortedRowModel,
17+
filterFns,
1818
injectTable,
1919
isFunction,
2020
rowPaginationFeature,
2121
rowSortingFeature,
22+
sortFns,
2223
tableFeatures,
2324
} from '@tanstack/angular-table'
2425
import { FormsModule } from '@angular/forms'
@@ -93,6 +94,14 @@ export class AppComponent {
9394

9495
table = injectTable<typeof _features, Person>(() => ({
9596
_features,
97+
_rowModels: {
98+
facetedMinMaxValues: createFacetedMinMaxValues(),
99+
facetedRowModel: createFacetedRowModel(),
100+
facetedUniqueValues: createFacetedUniqueValues(),
101+
filteredRowModel: createFilteredRowModel(filterFns),
102+
paginatedRowModel: createPaginatedRowModel(),
103+
sortedRowModel: createSortedRowModel(sortFns),
104+
},
96105
columns: this.columns,
97106
data: this.data(),
98107
state: {
@@ -103,13 +112,6 @@ export class AppComponent {
103112
? this.columnFilters.update(updater)
104113
: this.columnFilters.set(updater)
105114
},
106-
getCoreRowModel: createCoreRowModel(),
107-
getFilteredRowModel: createFilteredRowModel(), // client-side filtering
108-
getSortedRowModel: createSortedRowModel(),
109-
getPaginatedRowModel: createPaginatedRowModel(),
110-
getFacetedRowModel: createFacetedRowModel(), // client-side faceting
111-
getFacetedUniqueValues: createFacetedUniqueValues(), // generate unique values for select filter/autocomplete
112-
getFacetedMinMaxValues: createFacetedMinMaxValues(), // generate min/max values for range filter
113115
debugTable: true,
114116
debugHeaders: true,
115117
debugColumns: false,

examples/angular/grouping/src/app/app.component.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,14 @@ import {
77
} from '@angular/core'
88
import {
99
FlexRenderDirective,
10+
aggregationFns,
1011
columnFilteringFeature,
1112
columnGroupingFeature,
1213
createExpandedRowModel,
1314
createFilteredRowModel,
1415
createGroupedRowModel,
1516
createPaginatedRowModel,
17+
filterFns,
1618
injectTable,
1719
isFunction,
1820
rowExpandingFeature,
@@ -49,10 +51,10 @@ export class AppComponent {
4951
readonly table = injectTable(() => ({
5052
_features,
5153
_rowModels: {
52-
groupedRowModel: createGroupedRowModel(),
54+
groupedRowModel: createGroupedRowModel(aggregationFns),
5355
expandedRowModel: createExpandedRowModel(),
5456
paginatedRowModel: createPaginatedRowModel(),
55-
filteredRowModel: createFilteredRowModel(),
57+
filteredRowModel: createFilteredRowModel(filterFns),
5658
},
5759
enableExperimentalReactivity: true,
5860
data: this.data(),

examples/angular/row-selection-signal/src/app/app.component.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
columnVisibilityFeature,
1212
createFilteredRowModel,
1313
createPaginatedRowModel,
14+
filterFns,
1415
injectTable,
1516
rowPaginationFeature,
1617
rowSelectionFeature,
@@ -109,22 +110,12 @@ export class AppComponent {
109110
table = injectTable(() => ({
110111
_features,
111112
_rowModels: {
112-
filteredRowModel: createFilteredRowModel(),
113+
filteredRowModel: createFilteredRowModel(filterFns),
113114
paginatedRowModel: createPaginatedRowModel(),
114115
},
116+
columns: this.columns,
115117
data: this.data(),
116118
enableExperimentalReactivity: true,
117-
_features: {
118-
rowSelectionFeature,
119-
rowPaginationFeature,
120-
columnFilteringFeature,
121-
columnVisibilityFeature,
122-
},
123-
_rowModels: {
124-
filteredRowModel: createFilteredRowModel(),
125-
paginatedRowModel: createPaginatedRowModel(),
126-
},
127-
columns: this.columns,
128119
state: {
129120
rowSelection: this.rowSelection(),
130121
},

0 commit comments

Comments
 (0)