aggregate

Gets or sets the aggregate configuration.

Parameters

value Object|Array

The aggregate configuration. Accepts the same values as the aggregate option.

Returns

Array the current aggregate configuration.

Example - set the data source aggregates

<script>
var dataSource= new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ]
});
// calculate the minimum and maximum age
dataSource.aggregate([
  { field: "age", aggregate: "min" },
  { field: "age", aggregate: "max" }
]);
var ageAggregates = dataSource.aggregates().age;
console.log(ageAggregates.min); // displays "30"
console.log(ageAggregates.max); // displays "33"
</script>

Example - get the data source aggregates

<script>
var dataSource= new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ],
  aggregate: [
    { field: "age", aggregate: "min" },
    { field: "age", aggregate: "max" }
  ]
});
var aggregates = dataSource.aggregate();
console.log(kendo.stringify(aggregates[0])); // displays {"aggregate": "min", "field": "age"}
</script>

aggregates

Returns the aggregate results.

Returns

Object the aggregate results. There is a key for every aggregated field.

Example - get aggregate results

<script>
var dataSource= new kendo.data.DataSource({
  data: [
    { name: "Jane Doe", age: 30 },
    { name: "John Doe", age: 33 }
  ],
  aggregate: [
    { field: "age", aggregate: "min" },
    { field: "name", aggregate: "max" }
  ]
});
dataSource.read();
var ageAggregates = dataSource.aggregates().age;
console.log(ageAggregates.min); // displays "30"
console.log(ageAggregates.max); // displays "33"
</script>
In this article
Not finding the help you need?