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;
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(ageAggregates.min); // displays "30"
/* The result can be observed in the DevTools(F12) console of the browser. */
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();
/* The result can be observed in the DevTools(F12) console of the browser. */
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: "age", aggregate: "max" }
  ]
});
dataSource.read();
var ageAggregates = dataSource.aggregates().age;
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(ageAggregates.min); // displays "30"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(ageAggregates.max); // displays "33"
</script>
In this article