You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/framework/angular/guide/column-faceting.md
+5-3Lines changed: 5 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,9 @@ Want to skip to the implementation? Check out these Angular examples:
8
8
9
9
-[Faceted Filters](../examples/filters-faceted)
10
10
11
-
### Angular Setup
11
+
### Faceting Setup
12
+
13
+
Here's how you set up your table to use faceting features. Adding the faceting feature enables the related APIs. Additionally, if using client-side faceting, you also need to set up `filteredRowModel` and `facetedRowModel` after their associated features because row model slots are type-checked.
Copy file name to clipboardExpand all lines: docs/framework/angular/guide/column-filtering.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,15 +10,17 @@ Want to skip to the implementation? Check out these Angular examples:
10
10
-[Faceted Filters](../examples/filters-faceted)
11
11
-[Fuzzy Search](../examples/filters-fuzzy)
12
12
13
-
### Angular Setup
13
+
### Column Filtering Setup
14
+
15
+
Here's how you set up your table to use column filtering features. Adding the column filtering feature enables the related APIs. Additionally, if using client-side filtering, you also need to set up `filteredRowModel` after its associated feature because row model slots are type-checked.
Here's how you set up your table to use column resizing features. Column resizing depends on column sizing, so add `columnSizingFeature` before `columnResizingFeature`. Adding the column resizing feature enables the related APIs.
const features =tableFeatures({ columnResizingFeature })
20
+
const features =tableFeatures({
21
+
columnSizingFeature,
22
+
columnResizingFeature,
23
+
})
19
24
20
25
exportclassApp {
21
26
readonly data =signal(defaultData)
@@ -36,7 +41,7 @@ Column resizing builds on column sizing. If you only need to define starting, mi
36
41
37
42
### Enable Column Resizing
38
43
39
-
To use column resizing, add `columnResizingFeature` to your features. The `column.getCanResize()` API will return `true` by default for all columns, but you can either disable column resizing for all columns with the `enableColumnResizing` table option, or disable column resizing on a per-column basis with the `enableResizing` column option.
44
+
To use column resizing, add `columnSizingFeature` and then `columnResizingFeature` to your features. The `column.getCanResize()` API will return `true` by default for all columns, but you can either disable column resizing for all columns with the `enableColumnResizing` table option, or disable column resizing on a per-column basis with the `enableResizing` column option.
Copy file name to clipboardExpand all lines: docs/framework/angular/guide/composable-tables.md
+143-9Lines changed: 143 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,17 +1,147 @@
1
1
---
2
-
title: Composable Tables Guide
2
+
title: Composable Tables (createTableHook) Guide
3
3
---
4
4
5
-
Composable tables are app-level table factories built with `createTableHook`. Instead of repeating the same features, row models, default options, and table/cell/header components in every Angular table, you define that shared infrastructure once and consume it from each table component.
5
+
`createTableHook` creates an app-specific table factory. Use it to define shared features, row models, and default table options once, then create each Angular table with the columns and data that are unique to that table.
6
6
7
-
Use this pattern when multiple tables in an Angular app share behavior or rendering conventions. For a single isolated table, `injectTable` is usually enough.
7
+
The same API can also register reusable table, cell, and header components, but component registration is optional. Start with shared options and features first; add reusable components only when your app needs standardized table UI pieces.
8
8
9
9
## Examples
10
10
11
-
-[Composable Tables](../examples/composable-tables) - Two tables sharing one app table setup from `src/app/table.ts`.
12
11
-[Basic App Table](../examples/basic-app-table) - Minimal `createTableHook` usage without the larger component registry.
12
+
-[Composable Tables](../examples/composable-tables) - Richer Users and Products tables sharing `src/app/table.ts` and reusable components.
13
13
14
-
## Setup
14
+
## Start With Shared Features and Options
15
+
16
+
Create one app table hook and put the feature set, row models, and shared defaults there. This example makes sorting available to every table created by `injectAppTable`.
Options passed to `createTableHook` become defaults for every table created by `injectAppTable`. The `features` option is also bound to the returned column helper, so column definitions know that sorting APIs are available.
41
+
42
+
## Create App Columns
43
+
44
+
Create one column helper per row type. The helper is already bound to your app's feature set, so each table does not need to thread `typeof features` through its column definitions.
Create each table with `injectAppTable`. The call site provides table-specific inputs such as `columns` and `data`; shared features and defaults come from the hook.
77
+
78
+
```ts
79
+
exportclassUsersTable {
80
+
readonly data =signal<Array<Person>>([])
81
+
82
+
readonly table =injectAppTable(() => ({
83
+
key: 'users-table',
84
+
columns,
85
+
data: this.data(),
86
+
}))
87
+
}
88
+
```
89
+
90
+
## Render With The Normal Table APIs
91
+
92
+
You can render the table with the same table instance APIs used by a standalone `injectTable` table. This simple path does not require `appCell`, `appHeader`, `appFooter`, or registered components.
93
+
94
+
```html
95
+
<table>
96
+
<thead>
97
+
@for (headerGroup of table.getHeaderGroups(); track headerGroup.id) {
98
+
<tr>
99
+
@for (header of headerGroup.headers; track header.id) {
<ng-container*flexRenderHeader="header; let headerCell">
103
+
{{ headerCell }}
104
+
</ng-container>
105
+
}
106
+
</th>
107
+
}
108
+
</tr>
109
+
}
110
+
</thead>
111
+
<tbody>
112
+
@for (row of table.getRowModel().rows; track row.id) {
113
+
<tr>
114
+
@for (cell of row.getAllCells(); track cell.id) {
115
+
<td>
116
+
<ng-container*flexRenderCell="cell; let renderCell">
117
+
{{ renderCell }}
118
+
</ng-container>
119
+
</td>
120
+
}
121
+
</tr>
122
+
}
123
+
</tbody>
124
+
</table>
125
+
```
126
+
127
+
## Override Shared Defaults Per Table
128
+
129
+
Options passed to `injectAppTable` override defaults from `createTableHook`. Use this for the few tables that need different behavior without creating a separate app hook.
130
+
131
+
```ts
132
+
readonlytable=injectAppTable(() => ({
133
+
key: 'sortable-users-table',
134
+
columns,
135
+
data: this.data(),
136
+
enableSortingRemoval: true,
137
+
}))
138
+
```
139
+
140
+
## Optional: Reusable Components
141
+
142
+
The richer composable-tables example also uses `createTableHook` as a component registry. Use this when several tables should share the same toolbar controls, cell renderers, header renderers, or footer renderers.
143
+
144
+
### Component Registry Setup
15
145
16
146
The composable tables example keeps the shared setup in `src/app/table.ts`. That file creates one app-specific table factory and exports the helpers used by the rest of the example.
17
147
@@ -95,7 +225,7 @@ export const {
95
225
96
226
This file is the source of truth for the feature set, row model pipeline, row IDs, and registered components used by both tables in the example.
97
227
98
-
## Returned Helpers
228
+
###Returned Helpers
99
229
100
230
| Helper | Purpose |
101
231
|---|---|
@@ -105,7 +235,7 @@ This file is the source of truth for the feature set, row model pipeline, row ID
105
235
|`injectTableCellContext`| Reads the current cell inside registered cell components like `TextCell`. |
106
236
|`injectTableHeaderContext`| Reads the current header/footer inside registered header components like `SortIndicator`. |
107
237
108
-
## Columns
238
+
### Component Columns
109
239
110
240
Use `createAppColumnHelper<TData>()` instead of the base column helper when column definitions should render registered components.
The registered components are available through the enhanced `cell` and `header` objects because the column helper is bound to the `createTableHook` configuration.
134
264
135
-
## Table Rendering
265
+
### Component Table Rendering
136
266
137
267
Create each table with `injectAppTable`. Per-table options provide the data and columns; shared features and row models come from `src/app/table.ts`.
138
268
@@ -179,8 +309,12 @@ In templates, use the Angular rendering helpers with the app wrappers:
179
309
}
180
310
```
181
311
182
-
## Reusing The Hook
312
+
###Reusing The Component Registry
183
313
184
314
The example has separate Users and Products table components. Both import `createAppColumnHelper` and `injectAppTable` from `src/app/table.ts`, so they share sorting, filtering, pagination, row IDs, toolbar controls, cell renderers, and header/footer renderers while keeping their own data and columns.
185
315
186
316
If different product areas need incompatible defaults, create another `createTableHook` setup file and export a second set of app helpers from there.
317
+
318
+
## When To Use This Pattern
319
+
320
+
Use `createTableHook` when multiple tables should share features, row models, default options, or conventions. Use the standalone `injectTable` API for a one-off table. Add the component registry only when the app wants standardized reusable table UI pieces.
Copy file name to clipboardExpand all lines: docs/framework/angular/guide/expanding.md
+4-2Lines changed: 4 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,15 +8,17 @@ Want to skip to the implementation? Check out these Angular examples:
8
8
9
9
-[Expanding](../examples/expanding)
10
10
11
-
### Angular Setup
11
+
### Expanding Setup
12
+
13
+
Here's how you set up your table to use expanding features. Adding the expanding feature enables the related APIs. Additionally, if using client-side expanding, you also need to set up `expandedRowModel` after its associated feature because row model slots are type-checked.
0 commit comments