Edit this page

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;
  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 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;
  console.log(results.sum); // displays "63"
});
</script>

aggregate.field String

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

Example - specify 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;
  console.log(results.sum); // displays "63"
});
</script>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy