AdaptTable for ng-bootstrap

Tree data in ng-bootstrap

A tree grid is a different shape from a grouped table: the rows themselves nest, rather than being collected under synthetic headers. Compose tree() with getChildren or getParentId and it renders the hierarchy.

Children indent under their parent and a ng-bootstrap chevron control in the tree column opens and closes each branch. Give hasChildren and onLoadChildren and a branch fetches its children as it opens, showing that it is loading; a failed fetch closes it again, so the next click retries.

On a phone each card leads with the same chevron and indents by depth. Sorting reorders each branch in place, and a search shows the rows it matches.

The code

import { Component, input } from "@angular/core";
import type { ColumnDef } from "@adapttable/angular";
import { AdaptDataTable } from "@adapttable/ng-bootstrap";
import { tree } from "@adapttable/ng-bootstrap/tree";

interface Employee {
  id: string;
  name: string;
  team: string;
  managerId?: string;
}

const columns: ColumnDef<Employee>[] = [{ key: "name" }, { key: "team" }];

@Component({
  selector: "app-org",
  imports: [AdaptDataTable],
  template: `
    <adapt-data-table
      [data]="people()"
      [columns]="columns"
      [rowKey]="rowKey"
      [features]="features"
    />
  `,
})
export class Org {
  readonly people = input.required<readonly Employee[]>();
  readonly columns = columns;
  readonly rowKey = (row: Employee) => row.id;
  readonly features = [
    tree<Employee>({ getParentId: (row) => row.managerId, treeColumn: "name" }),
  ];
}

Install

# Follow the kit setup guide for compatible peers
pnpm add @adapttable/ng-bootstrap @adapttable/angular @ng-bootstrap/ng-bootstrap@21.0.0 @popperjs/core@2.11.8 @angular/forms@^22 @angular/localize@^22 rxjs@^7.4.0

The same feature in the other kits

More ng-bootstrap features

Reference: tree-data. More of this kit: AdaptTable for ng-bootstrap, or the live demo.