Aggregates in Vue Treegrid component

24 Mar 20235 minutes to read

Aggregate values are displayed in the TreeGrid footer and in parent row footer for child row aggregate values. It can be configured through aggregates property. field and type are the minimum properties required to represent an aggregate column.

To use the aggregate feature, you have to inject the Aggregate module.

By default, the aggregate value can be displayed in the treegrid footer, and footer of child rows. To show the aggregate value in one of the cells, use the footerTemplate.

To get start quickly with aggregates in Vue tree grid component, you can check on this video:

Built-in aggregate types

The aggregate type should be specified in the type property to configure an aggregate column.

The built-in aggregates are,

  • Sum
  • Average
  • Min
  • Max
  • Count
  • Truecount
  • Falsecount
  • Multiple aggregates can be used for an aggregate column by setting the type property
    with an array of aggregate types.
  • Multiple types for a column is supported only when one of the aggregate templates is used.

Child aggregate

Aggregate value is calculated for child rows, and it is displayed in the parent row footer. Use the childSummary property to render the child rows aggregate value.

<div id="app">
        <ejs-treegrid :dataSource="data" childMapping='children' :treeColumnIndex='1' height='260px'>
                <e-column field='FreightID' headerText='Freight ID' width=90 textAlign='Right'></e-column>
                <e-column field='FreightName' headerText='Freight Name' width=180></e-column>
                <e-column field='UnitWeight' headerText='Unit Per Weight' width=90 type='number'textAlign='Right'></e-column>
                <e-column field='TotalUnits' headerText='Total Units' type='number' width=80 textAlign='Right'></e-column>
                <e-aggregate :showChildSummary='true'>
                        <e-column type="Max" field="UnitWeight" :footerTemplate='footerMax'></e-column>
                        <e-column type="Min" field="TotalUnits" :footerTemplate='footerMin'></e-column>
import Vue from "vue";
import { TreeGridPlugin, Aggregate } from "@syncfusion/ej2-vue-treegrid";
import { summaryRowData } from "./datasource.js";


export default {
  data() {
    return {
      data: summaryRowData,
            footerMin: function () {
        return  { template : Vue.component('minTemplate', {
            template: `<span>Min: </span>`,
            data () {return { data: {}};}
      footerMax: function () {
        return  { template : Vue.component('maxTemplate', {
            template: `<span>Max: </span>`,
            data () {return { data: {}};}
    provide: {
      treegrid: [Aggregate]