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

Grid with aggregates data bug

1 Answer 145 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Oren
Top achievements
Rank 1
Oren asked on 17 Jun 2014, 12:00 PM
Hello ,
maybe you can help me with some issue.

I use kendo grid, I have grid with
aggregates data, and it looks like that:

 Grid:
(attach as grid.jpg)

Aggregates: (I don't use all the aggregates)
(attach as Aggregates.jpg)

I save the grid state (paging, grouping,
sorting, filtering and aggregates) in cookie as (Java Script):

var gridState = {           
       page: dataSource.page(),           
       pageSize: dataSource.pageSize(),           
       sort: dataSource.sort(),           
       group: dataSource.group(),
       filter: dataSource.filter(),
      aggregates: dataSource.aggregates()
        };

Cookie (JSON) (Result of saving):
{"page":1,"pageSize":11,"group":[{"field":"Modality","dir":"asc","aggregates":[{"field":"Space","aggregate":"count"},{"field":"Priority","aggregate":"min"},{"field":"Priority","aggregate":"max"},{"field":"Priority","aggregate":"count"},{"field":"Priority","aggregate":"average"}]}],"aggregates":{"Priority":{"min":1,"max":4,"count":148,"average":3.0135135135135136},"Space":{"count":148}}}

And I try to restoring the grid from
cookie that I already save, I loaded it like that:

Restoring the grid state: (paging, grouping , sorting and filtering)
if (gridState!= '' && gridState!= null) {   
      grid.dataSource.query(gridState);


But unfortunately is not work when I use
aggregate, an exception was throw:
"Uncaught ReferenceError: count is not defined"

And I don't understand it because I have count:
(attach as count.jpg)

Anyway those errors occurs just when I started use aggregates. before it, everything work just fine!

Thanks in advance.

Oren.

1 Answer, 1 is accepted

Sort by
0
Alexander Popov
Telerik team
answered on 19 Jun 2014, 08:59 AM
Hello Oren,

The DataSource's aggregates method returns an object containing the result of the aggregates. When querying the DataSource, you need to pass not the values, but the configuration of the aggregates, so the DataSource could re-calculate them based on the current data. You can get the configuration using the aggregate method (not to be confused with aggregates).

Regards,
Alexander Popov
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
Grid
Asked by
Oren
Top achievements
Rank 1
Answers by
Alexander Popov
Telerik team
Share this question
or