AdaptTable for shadcn-vue

Aggregation in shadcn-vue

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 shadcn-vue controls on desktop and in phone cards.

The code

<script setup lang="ts">
import { computed } from "vue";
import { aggregate, type ColumnDef } from "@adapttable/vue";
import { DataTable } from "@adapttable/shadcn-vue";
import { groupingPanel } from "@adapttable/shadcn-vue/grouping-panel";
import { pinnedSummaryRows } from "@adapttable/shadcn-vue/pinned-summary-rows";

const props = defineProps<{
  rows: readonly Person[];
  totals: readonly Person[];
}>();

const columns: ColumnDef<Person>[] = [
  { key: "name" }, { key: "team" }, { key: "budget" },
];
const rowKey = (row: Person) => row.id;
const budgetSum = aggregate<Person>({ budget: "sum" });
const features = computed(() => [
  groupingPanel<Person>("team", {
    groupAggregates: budgetSum, groupFooters: true,
  }),
  pinnedSummaryRows<Person>({ top: props.totals }),
]);
</script>

<template>
  <DataTable
    :data="rows" :columns="columns" :row-key="rowKey"
    :summary-row="budgetSum" :features="features"
  />
</template>

Install

pnpm add @adapttable/shadcn-vue @adapttable/vue @adapttable/core reka-ui

The same feature in the other kits

More shadcn-vue features

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