AdaptTable for Vue Unstyled

Aggregation in Vue Unstyled

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 Vue Unstyled 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/vue-unstyled";
import { groupingPanel } from "@adapttable/vue-unstyled/grouping-panel";
import { pinnedSummaryRows } from "@adapttable/vue-unstyled/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/vue-unstyled @adapttable/vue @adapttable/core

The same feature in the other kits

More Vue Unstyled features

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