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

How to set formula to calculate in groupHeaderTemplate

4 Answers 447 Views
Grid
This is a migrated thread and some comments may be shown as answers.
krishnan
Top achievements
Rank 1
krishnan asked on 02 Sep 2016, 11:23 AM
Hi,

I would like to know how to set the group header template which displays data after calculating from multiple column values. The formula is something like sum(col_x_value * col_y_value) / sum of col_x_value after grouping. This data should display for each and every grouped header.

Looking forward towards your reply.

Thanks in advance.

4 Answers, 1 is accepted

Sort by
0
Kiril Nikolov
Telerik team
answered on 06 Sep 2016, 06:41 AM
Hi,

You can execute a function inside the template. Please see the following example:

http://dojo.telerik.com/AHUzO

Regards,
Kiril Nikolov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
0
krishnan
Top achievements
Rank 1
answered on 06 Sep 2016, 10:01 AM

Hi,

In http://dojo.telerik.com/AHUzO only "age" value is getting passed to the foo function. How can I pass other column values to it?.

Please find the code snippet here

I want to display Percentage : Sum ( item1 values in that group * item2 values in that group ) / sum ( item1 values in that group )

For example, the first group should display Percentage : 27.5

( (21 * 28) + (21 * 27) ) / (21 + 21) = 1155 / 42 = 27.5

Thanks.

 

0
krishnan
Top achievements
Rank 1
answered on 06 Sep 2016, 10:17 AM

Hi,

In http://dojo.telerik.com/AHUzO only age field value is getting passed to the foo function. How to pass other column values to it?

Please find the code snippet here.

I want to display Percentage value in each group header.

Example:

Percentage : Sum ( item1 values in that group * item2 values in that group ) / sum ( item1 values in that group )

For the first group: ( ( 21 * 28 ) + ( 21 * 27 ) ) / ( 21 + 21 )  = 1155 / 42 = 27.5

So, first group header should display Percentage : 27.5

Also, please let me know if I can set group header template globally.

Thanks

0
Kiril Nikolov
Telerik team
answered on 08 Sep 2016, 07:03 AM
Hello,

In the function you can just get a reference to the dataSource and get all the aggregates using the aggregates method documented here:

http://docs.telerik.com/kendo-ui/api/javascript/data/datasource

Regards,
Kiril Nikolov
Telerik by Progress
 
Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
 
Tags
Grid
Asked by
krishnan
Top achievements
Rank 1
Answers by
Kiril Nikolov
Telerik team
krishnan
Top achievements
Rank 1
Share this question
or