@@ -5,21 +5,29 @@ import {
55 signal ,
66} from '@angular/core'
77import {
8- ColumnDef ,
9- createAngularTable ,
10- ExpandedState ,
11- flexRenderComponent ,
128 FlexRenderDirective ,
13- getCoreRowModel ,
14- getExpandedRowModel ,
15- getFilteredRowModel ,
16- getPaginationRowModel ,
9+ createExpandedRowModel ,
10+ createPaginatedRowModel ,
11+ createTableHelper ,
12+ flexRenderComponent ,
13+ rowExpandingFeature ,
14+ rowPaginationFeature ,
15+ rowSelectionFeature ,
16+ tableFeatures ,
1717} from '@tanstack/angular-table'
18- import { makeData , type Person } from './makeData'
1918import { ReactiveFormsModule } from '@angular/forms'
19+ import { makeData } from './makeData'
2020import { ExpandableCell , ExpandableHeaderCell } from './expandable-cell'
21+ import type { Person } from './makeData'
22+ import type { ColumnDef , ExpandedState } from '@tanstack/angular-table'
23+
24+ const _features = tableFeatures ( {
25+ rowExpandingFeature : rowExpandingFeature ,
26+ rowPaginationFeature : rowPaginationFeature ,
27+ rowSelectionFeature : rowSelectionFeature ,
28+ } )
2129
22- const defaultColumns : ColumnDef < Person > [ ] = [
30+ const defaultColumns : Array < ColumnDef < typeof _features , Person > > = [
2331 {
2432 accessorKey : 'firstName' ,
2533 header : ( ) =>
@@ -66,10 +74,18 @@ const defaultColumns: ColumnDef<Person>[] = [
6674 changeDetection : ChangeDetectionStrategy . OnPush ,
6775} )
6876export class AppComponent {
69- readonly data = signal < Person [ ] > ( makeData ( 100 , 5 , 3 ) )
77+ readonly data = signal < Array < Person > > ( makeData ( 100 , 5 , 3 ) )
7078 readonly expanded = signal < ExpandedState > ( { } )
7179
72- readonly table = createAngularTable ( ( ) => ( {
80+ readonly tableHelper = createTableHelper ( {
81+ _features,
82+ _rowModels : {
83+ paginatedRowModel : createPaginatedRowModel ( ) ,
84+ expandedRowModel : createExpandedRowModel ( ) ,
85+ } ,
86+ } )
87+
88+ readonly table = this . tableHelper . injectTable ( ( ) => ( {
7389 data : this . data ( ) ,
7490 columns : defaultColumns ,
7591 state : {
@@ -80,10 +96,6 @@ export class AppComponent {
8096 ? this . expanded . update ( updater )
8197 : this . expanded . set ( updater ) ,
8298 getSubRows : ( row ) => row . subRows ,
83- getCoreRowModel : getCoreRowModel ( ) ,
84- getPaginationRowModel : getPaginationRowModel ( ) ,
85- getFilteredRowModel : getFilteredRowModel ( ) ,
86- getExpandedRowModel : getExpandedRowModel ( ) ,
8799 // filterFromLeafRows: true,
88100 // maxLeafRowFilterDepth: 0,
89101 debugTable : true ,
0 commit comments