aggregate Array

The aggregates which are calculated when the data source populates with data.

The supported aggregates are:

  • "average" - Only for Number.
  • "count" - String, Number and Date.
  • "max" - Number and Date.
  • "min" - Number and Date.
  • "sum" - Only for Number.

The data source calculates aggregates client-side unless the serverAggregates option is set to true.

Example - specify aggregates

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ],
  aggregate: [
    { field: "age", aggregate: "sum" },
    { field: "age", aggregate: "min" },
    { field: "age", aggregate: "max" }
  ]
});
dataSource.fetch(function(){
  var results = dataSource.aggregates().age;
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(results.sum, results.min, results.max); // displays "63 30 33"
});
</script>

aggregate.aggregate String

The name of the aggregate function.

The supported aggregates are:

  • "average"
  • "count"
  • "max"
  • "min"
  • "sum"

Example - specify an aggregate function

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ],
  aggregate: [
    { field: "age", aggregate: "sum" }
  ]
});
dataSource.fetch(function(){
  var results = dataSource.aggregates().age;
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(results.sum); // displays "63"
});
</script>

aggregate.field String

The data item field which will be used to calculate the aggregates.

Example - specify an aggregate field

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ],
  aggregate: [
    { field: "age", aggregate: "sum" }
  ]
});
dataSource.fetch(function(){
  var results = dataSource.aggregates().age;
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(results.sum); // displays "63"
});
</script>
In this article