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

add aggregate to DataSource (after populating with data)

2 Answers 313 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 14 Jun 2013, 03:28 PM
I have a VM has a DataSource in it.

var layerTable = new kendo.data.DataSource();
When new data arrives, I am able to populate the LayerTable with the data() function. But I also want to dynamically add in aggragates to this.

1.vm.SetLayers = function(values) {
2.    this.LayerTable.data(values);
3.    this.LayerTable.aggregate = [{ field: "FileCount", aggregate: "count" }];
4.    //this.trigger("change", { field: "LayerTable" });
5.};
I am finding that when I later try to get the aggregates() I get an empty object.

1.vm.LayerTable.aggregates();

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 18 Jun 2013, 09:59 AM
Hi,

You should use the aggregate method.

Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Accepted
Dr.YSG
Top achievements
Rank 2
answered on 18 Jun 2013, 02:07 PM
Yes, that is a typo on my part.

I am now able to do what I thought was not possible.

1. Setup (at init time) the DataSource, with aggregates() but with no data
2. Receive JSON via XHR
3. do a DataSource.data() and supply the new data, and behold, the aggregates() values are filled in.

Tags
Data Source
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Daniel
Telerik team
Dr.YSG
Top achievements
Rank 2
Share this question
or