AdaptTable for Spartan

Aggregation in Spartan

aggregate() computes the table footer and each team's groupAggregates; groupFooters closes each team with its subtotal.

Search the table and group totals and the footer recompute from matching rows. The host-owned portfolio total uses pinnedSummaryRows and remains above the scrolling body, independent of filtering and sorting.

All three surfaces render through the same Spartan controls on desktop and in phone cards.

The code

import { Component, computed, input } from "@angular/core";
import { aggregate, type ColumnDef } from "@adapttable/angular";
import { AdaptDataTable } from "@adapttable/spartan";
import { groupingPanel } from "@adapttable/spartan/grouping-panel";
import { pinnedSummaryRows } from "@adapttable/spartan/pinned-summary-rows";

@Component({
  selector: "app-totals",
  imports: [AdaptDataTable],
  template: `
    <adapt-data-table
      [data]="rows()" [columns]="columns" [rowKey]="rowKey"
      [summaryRow]="budgetSum" [features]="features()"
    />
  `,
})
export class Totals {
  readonly rows = input.required<readonly Person[]>();
  readonly totals = input.required<readonly Person[]>();
  readonly columns: ColumnDef<Person>[] = [
    { key: "name" }, { key: "team" }, { key: "budget" },
  ];
  readonly rowKey = (row: Person) => row.id;
  readonly budgetSum = aggregate<Person>({ budget: "sum" });
  readonly features = computed(() => [
    groupingPanel<Person>("team", {
      groupAggregates: this.budgetSum, groupFooters: true,
    }),
    pinnedSummaryRows<Person>({ top: this.totals() }),
  ]);
}

Install

# Follow the kit setup guide for compatible peers
pnpm add @adapttable/spartan @adapttable/angular @spartan-ng/brain@1.5.0 @angular/cdk@^22 @angular/forms@^22 rxjs@^7.8.0 tailwindcss@^4 clsx@^2.1.1 tw-animate-css@^1

The same feature in the other kits

More Spartan features

Reference: row-grouping, pinned-summary-rows, full-width-rows. More of this kit: AdaptTable for Spartan, or the live demo.