This is a migrated thread and some comments may be shown as answers.

Datasource Aggregates

2 Answers 487 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Andrew
Top achievements
Rank 1
Andrew asked on 28 Dec 2011, 12:35 AM
Can someone supply a brief example of proper syntax for defining and accessing aggregates on a datasource?   I am unable to access any aggregates results (function keeps returning UNDEFINED).   I must be missing something trivial.  Modified fiddle sample I am experimenting with:

http://jsfiddle.net/divotfixer/QwQwF/

2 Answers, 1 is accepted

Sort by
0
Accepted
Nikolay Rusev
Telerik team
answered on 28 Dec 2011, 09:59 AM
Hello Andrew,

The aggregates method returns a object which as keys has the field name and as value the another object that contains the value for every aggregate. I.e you should retrieve the sum aggregate for stock field as follow:
dataSource.aggregates().stock.sum

Another thing you should notice is that when you call any method that applies some sort of transformations of the data you should handle change event of the DataSource. This event will be triggered when the data manipulation is finished and you can be sure that the data you access is the latest.

For more details please see the updated version of the fiddle from your post:
http://jsfiddle.net/rusev/NwG9A/2/

All the best,
Nikolay Rusev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Andrew
Top achievements
Rank 1
answered on 28 Dec 2011, 05:21 PM
Awesome!  Thanks for the quick reply...
Tags
Data Source
Asked by
Andrew
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Andrew
Top achievements
Rank 1
Share this question
or