AdaptTable for Element Plus

Aggregation in Element Plus

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 Element Plus 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/element-plus";
import { groupingPanel } from "@adapttable/element-plus/grouping-panel";
import { pinnedSummaryRows } from "@adapttable/element-plus/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/element-plus @adapttable/vue @adapttable/core element-plus

The same feature in the other kits

More Element Plus features

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