File: grouping.md | Updated: 11/15/2025
Search...
+ K
Auto
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples GitHub Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Docs Examples Github Contributors
Maintainers Partners Support Learn StatsBETA Discord Merch Blog GitHub Ethos Brand Guide
Documentation
Framework
Angular
Version
v8
Search...
+ K
Menu
Getting Started
Core Guides
Feature Guides
Core APIs
Feature APIs
Enterprise
Examples
Framework
Angular
Version
v8
Menu
Getting Started
Core Guides
Feature Guides
Core APIs
Feature APIs
Enterprise
Examples
Angular Example: Grouping
=======================================================================================================================================================================================================================================================================================================================================================================================================================================
Code ExplorerCode
Interactive SandboxSandbox
.devcontainer
src
app
app.component.html
app.component.ts
app.config.ts
columns.ts
makeData.ts
assets
favicon.ico
index.html
main.ts
styles.scss
.editorconfig
.gitignore
README.md
angular.json
package.json
tsconfig.app.json
tsconfig.json
tsconfig.spec.json
ts
import { CommonModule } from '@angular/common'
import {
ChangeDetectionStrategy,
Component,
computed,
signal,
} from '@angular/core'
import {
FlexRenderDirective,
GroupingState,
Updater,
createAngularTable,
getCoreRowModel,
getExpandedRowModel,
getFilteredRowModel,
getGroupedRowModel,
getPaginationRowModel,
} from '@tanstack/angular-table'
import { columns } from './columns'
import { makeData } from './makeData'
@Component({
selector: 'app-root',
standalone: true,
imports: [FlexRenderDirective, CommonModule],
templateUrl: './app.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {
title = 'grouping'
data = signal(makeData(10000))
grouping = signal<GroupingState>([])
stringifiedGrouping = computed(() => JSON.stringify(this.grouping(), null, 2))
tableOptions = computed(() => ({
data: this.data(),
columns: columns,
state: {
grouping: this.grouping(),
},
onGroupingChange: (updaterOrValue: Updater<GroupingState>) => {
const groupingState =
typeof updaterOrValue === 'function'
? updaterOrValue([...this.grouping()])
: updaterOrValue
this.grouping.set(groupingState)
},
getExpandedRowModel: getExpandedRowModel(),
getGroupedRowModel: getGroupedRowModel(),
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getFilteredRowModel: getFilteredRowModel(),
debugTable: true,
}))
table = createAngularTable(this.tableOptions)
onPageInputChange(event: any): void {
const page = event.target.value ? Number(event.target.value) - 1 : 0
this.table.setPageIndex(page)
}
onPageSizeChange(event: any) {
this.table.setPageSize(Number(event.target.value))
}
refreshData() {
this.data.set(makeData(10000))
}
}
import { CommonModule } from '@angular/common'
import {
ChangeDetectionStrategy,
Component,
computed,
signal,
} from '@angular/core'
import {
FlexRenderDirective,
GroupingState,
Updater,
createAngularTable,
getCoreRowModel,
getExpandedRowModel,
getFilteredRowModel,
getGroupedRowModel,
getPaginationRowModel,
} from '@tanstack/angular-table'
import { columns } from './columns'
import { makeData } from './makeData'
@Component({
selector: 'app-root',
standalone: true,
imports: [FlexRenderDirective, CommonModule],
templateUrl: './app.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class AppComponent {
title = 'grouping'
data = signal(makeData(10000))
grouping = signal<GroupingState>([])
stringifiedGrouping = computed(() => JSON.stringify(this.grouping(), null, 2))
tableOptions = computed(() => ({
data: this.data(),
columns: columns,
state: {
grouping: this.grouping(),
},
onGroupingChange: (updaterOrValue: Updater<GroupingState>) => {
const groupingState =
typeof updaterOrValue === 'function'
? updaterOrValue([...this.grouping()])
: updaterOrValue
this.grouping.set(groupingState)
},
getExpandedRowModel: getExpandedRowModel(),
getGroupedRowModel: getGroupedRowModel(),
getCoreRowModel: getCoreRowModel(),
getPaginationRowModel: getPaginationRowModel(),
getFilteredRowModel: getFilteredRowModel(),
debugTable: true,
}))
table = createAngularTable(this.tableOptions)
onPageInputChange(event: any): void {
const page = event.target.value ? Number(event.target.value) - 1 : 0
this.table.setPageIndex(page)
}
onPageSizeChange(event: any) {
this.table.setPageSize(Number(event.target.value))
}
refreshData() {
this.data.set(makeData(10000))
}
}
