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

using sum in row cell

1 Answer 937 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Boschi
Top achievements
Rank 1
Boschi asked on 06 Oct 2017, 09:22 AM

Hi, I've got a grid containing a list of elements with a corresponding numeric value, where I use the aggregate functions to show the sum in the footer. Something like this:

ELEMENTS  |  VALUE

element1       |      1

element2       |      2

element3       |      3

---------------------------------

TOTAL           |      6

 

now I need to show beside the row number the percentual relative to the total, this way:

ELEMENTS  |  VALUE
element1       |      1 (16.67%)
element2       |      2 (33.33%)
element3       |      3 (50.00%)
---------------------------------
TOTAL           |      6

so I add to the VALUE column options this:

template: "#:value#<br>#=100*value/sum#%"

but the grid stops working, without even showing errors in the console. What am I missing?

1 Answer, 1 is accepted

Sort by
0
Georgi
Telerik team
answered on 10 Oct 2017, 06:14 AM
Hi Boschi,

Possible solution is to pass a function to the column.template property. Then access the aggregates using aggregates method and create the template:



Regards,
Georgi
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
Grid
Asked by
Boschi
Top achievements
Rank 1
Answers by
Georgi
Telerik team
Share this question
or