Row Expansion (Sub rows)

Row expansion enables tables to display hierarchical data by allowing rows to expand and reveal nested sub-rows. This is useful for representing parent-child relationships, grouped data, or tree structures within a table.

The demo below shows a table with expandable rows containing nested data. Each row with children displays an expand button that toggles visibility of its sub-rows. The header includes an expand-all button that expands or collapses all rows at once. Visual indentation indicates the depth level of each row in the hierarchy.


Username
Account Status Role Avg Session Duration Company Name Last Visited At Visit Count
Dorothea.VonRueden30
pending admin 72 Stehr - Lueilwitz 26 Aug 2025 21:27:31 PDT 377
Shawn_Roob
active moderator 119 Schulist, Hamill and Rogahn 13 Oct 2025 13:19:15 PDT 2
Terrell.Boehm65
active moderator 118 Ziemann Group 30 Aug 2024 02:12:21 PDT 53
Grayson.Parisian27
suspended user 106 Bernier Group 20 Oct 2025 16:23:07 PDT 24
Maegan_Haag
pending moderator 86 Bradtke Inc 13 Mar 2025 05:43:39 PDT 52
Leonard.Prosacco-Hane93
suspended admin 95 Hudson - Jacobi-Huel 23 Aug 2025 00:45:12 PDT 16
Darren_Walsh
active user 98 Douglas, Gulgowski and Hoeger 28 Sep 2025 18:34:30 PDT 203
Johanna_Robel
pending moderator 116 Hills - Walsh 26 May 2025 11:15:55 PDT 68
Nova_Davis
pending user 60 Wunsch - Roberts-Moore 11 Sep 2025 14:38:36 PDT 19
Eden.OKeefe
pending user 47 Goldner, Durgan and O'Connell-Jenkins 21 Feb 2025 07:44:32 PDT 5
import {Component} from "@angular/core"

import {ButtonModule} from "@qualcomm-ui/angular/button"
import {PaginationModule} from "@qualcomm-ui/angular/pagination"
import {ProgressRingModule} from "@qualcomm-ui/angular/progress-ring"
import {
  createAngularTable,
  createTablePagination,
  TableModule,
} from "@qualcomm-ui/angular/table"
import {
  getCoreRowModel,
  getExpandedRowModel,
  getPaginationRowModel,
} from "@qualcomm-ui/core/table"

import {createUserQuery, type User, userColumns} from "./data"

@Component({
  imports: [TableModule, PaginationModule, ButtonModule, ProgressRingModule],
  selector: "row-expansion-demo",
  template: `
    <div q-table-root>
      <div q-table-action-bar>
        <button
          q-button
          size="sm"
          variant="outline"
          [disabled]="query.isFetching()"
          (click)="query.refetch()"
        >
          Refresh Data
        </button>
        @if (query.isFetching()) {
          <div q-progress-ring size="xs"></div>
        }
      </div>
      <div q-table-scroll-container>
        <table q-table-table>
          <thead q-table-header>
            @for (
              headerGroup of table.getHeaderGroups();
              track headerGroup.id
            ) {
              <tr q-table-row>
                @for (header of headerGroup.headers; track header.id) {
                  <th q-table-header-cell>
                    <ng-container *renderHeader="header; let value">
                      {{ value }}
                    </ng-container>
                  </th>
                }
              </tr>
            }
          </thead>
          <tbody q-table-body>
            @for (row of table.getRowModel().rows; track row.id) {
              <tr q-table-row>
                @for (cell of row.getVisibleCells(); track cell.id) {
                  <td q-table-cell>
                    <ng-container *renderCell="cell; let value">
                      {{ value }}
                    </ng-container>
                  </td>
                }
              </tr>
            }
          </tbody>
        </table>
      </div>
      <div
        q-table-pagination
        [count]="pagination.count()"
        [page]="pagination.page()"
        [pageSize]="pagination.pageSize()"
        (pageChanged)="pagination.onPageChange($event)"
      >
        <div *paginationContext="let context" q-pagination-page-metadata>
          @let meta = context.pageMetadata;
          {{ meta.pageStart }}-{{ meta.pageEnd }} of {{ meta.count }} results
        </div>

        <div q-pagination-page-buttons></div>
      </div>
    </div>
  `,
})
export class RowExpansionDemo {
  protected readonly query = createUserQuery(100, 5, 3)

  protected table = createAngularTable<User>(() => ({
    columns: userColumns,
    data: this.query.data() || [],
    getCoreRowModel: getCoreRowModel(),
    getExpandedRowModel: getExpandedRowModel(),
    getPaginationRowModel: getPaginationRowModel(),
    getSubRows: (row: User) => row.subRows,
  }))

  protected pagination = createTablePagination(this.table)
}
Updated by Ryan Bower