@@ -7,12 +7,16 @@ import {
77} from '@angular/core'
88import {
99 FlexRenderDirective ,
10+ columnFilteringFeature ,
11+ columnGroupingFeature ,
1012 createCoreRowModel ,
1113 createExpandedRowModel ,
1214 createFilteredRowModel ,
1315 createGroupedRowModel ,
1416 createPaginatedRowModel ,
1517 injectTable ,
18+ rowExpandingFeature ,
19+ rowPaginationFeature ,
1620 tableOptions ,
1721} from '@tanstack/angular-table'
1822import { columns } from './columns'
@@ -28,35 +32,42 @@ import type { GroupingState, Updater } from '@tanstack/angular-table'
2832} )
2933export class AppComponent {
3034 title = 'grouping'
31- data = signal ( makeData ( 10000 ) )
32- grouping = signal < GroupingState > ( [ ] )
35+ readonly data = signal ( makeData ( 10000 ) )
36+ readonly grouping = signal < GroupingState > ( [ ] )
3337
34- stringifiedGrouping = computed ( ( ) => JSON . stringify ( this . grouping ( ) , null , 2 ) )
35-
36- tableOptions = computed ( ( ) =>
37- tableOptions ( {
38- data : this . data ( ) ,
39- columns : columns ,
40- state : {
41- grouping : this . grouping ( ) ,
42- } ,
43- onGroupingChange : ( updaterOrValue : Updater < GroupingState > ) => {
44- const groupingState =
45- typeof updaterOrValue === 'function'
46- ? updaterOrValue ( [ ...this . grouping ( ) ] )
47- : updaterOrValue
48- this . grouping . set ( groupingState )
49- } ,
50- getExpandedRowModel : createExpandedRowModel ( ) ,
51- getGroupedRowModel : createGroupedRowModel ( ) ,
52- getCoreRowModel : createCoreRowModel ( ) ,
53- getPaginatedRowModel : createPaginatedRowModel ( ) ,
54- getFilteredRowModel : createFilteredRowModel ( ) ,
55- debugTable : true ,
56- } ) ,
38+ readonly stringifiedGrouping = computed ( ( ) =>
39+ JSON . stringify ( this . grouping ( ) , null , 2 ) ,
5740 )
5841
59- table = injectTable ( this . tableOptions )
42+ readonly table = injectTable ( ( ) => ( {
43+ data : this . data ( ) ,
44+ columns : columns ,
45+ initialState : {
46+ pagination : { pageSize : 20 , pageIndex : 0 } ,
47+ } ,
48+ state : {
49+ grouping : this . grouping ( ) ,
50+ } ,
51+ _features : {
52+ columnGroupingFeature,
53+ rowPaginationFeature,
54+ columnFilteringFeature,
55+ rowExpandingFeature,
56+ } ,
57+ _rowModels : {
58+ groupedRowModel : createGroupedRowModel ( ) ,
59+ expandedRowModel : createExpandedRowModel ( ) ,
60+ paginatedRowModel : createPaginatedRowModel ( ) ,
61+ filteredRowModel : createFilteredRowModel ( ) ,
62+ } ,
63+ onGroupingChange : ( updaterOrValue : Updater < GroupingState > ) => {
64+ const groupingState =
65+ typeof updaterOrValue === 'function'
66+ ? updaterOrValue ( [ ...this . grouping ( ) ] )
67+ : updaterOrValue
68+ this . grouping . set ( groupingState )
69+ } ,
70+ } ) )
6071
6172 onPageInputChange ( event : any ) : void {
6273 const page = event . target . value ? Number ( event . target . value ) - 1 : 0
0 commit comments