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

RadGrid, use calculated fields in group and grand footers

8 Answers 116 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 16 May 2012, 08:39 PM

I’m using a radgrid with boundcolumns, some of the columns are displayed as percentages.  How would I display percentages in the group footer and the grand total footer?   It's easy to sum, count fields in footers but I'm stumped with how to create calculated fields in footers.

The percentage would be calculated by sum of one column divided by the other.  I looked at the example that uses the CustomAggregates event but if I used that then it would have to create a datatable for every percentage column for every group which would be significant overhead. 

 

Let me know if you have any suggestions.

 

Thanks,

Bob

8 Answers, 1 is accepted

Sort by
0
Brian
Top achievements
Rank 1
answered on 16 Aug 2012, 08:51 PM
Did anyone ever respond to this inquiry? I have the same question.
0
Marin
Telerik team
answered on 21 Aug 2012, 01:14 PM
Hi,

 You can use the GridCalculatedColumn as shown in this demo:
http://demos.telerik.com/aspnet-ajax/grid/examples/groupby/groupfooter/defaultcs.aspx 

All the best,
Marin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Daniel
Top achievements
Rank 1
answered on 11 Oct 2016, 06:38 PM

GridCalculatedColumn does not provide a proper calculation for percentages of an aggregate footer row.

For example, I have 4 rows of percentages (0%, 50%, 100%, 100%) calculated from Row1 / TotalsColumn, and the footer row percentage shows up as 250% if I set the property Aggregate="Sum".

The Row1 values (0,1,1,3) total to 5, the TotalsColumn values (1,2,1,3) total to 7. This calculates to 71.43%.

Please provide an appropriate answer.

0
Marin
Telerik team
answered on 12 Oct 2016, 08:32 AM
Hello,

You can use custom aggregates to calculate the required value as shown in this help article:
http://docs.telerik.com/devtools/aspnet-ajax/controls/grid/how-to/totals-in-grid-footers

Regards,
Marin
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
Pradeep
Top achievements
Rank 1
answered on 02 Jun 2017, 03:17 PM
Can anyone please post appropriate solution here for aggregating a percentage column?
0
Eyup
Telerik team
answered on 07 Jun 2017, 06:42 AM
Hello Pradeep,

Generally, you can use one of the built-in Aggregate options:
<telerik:GridNumericColumn ... DataFormatString="{0:P}"  Aggregate="Avg">

Alternatively, you can calculate your own preferred value similar to the approach demonstrated in the attached web site sample.

I hope this will prove helpful.

Regards,
Eyup
Progress Telerik
Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
0
Amanda
Top achievements
Rank 1
answered on 17 Jul 2019, 06:46 PM

//bind the data to the grid

grdCommissionEstimate.DataBind();

//gets the footer row
GridFooterItem footerItem = (GridFooterItem)grdCommissionEstimate.MasterTableView.GetItems(GridItemType.Footer)[0];

//this looks up the text by the DataField value and pulls the footer total, then does the math
Decimal ThePercent = Math.Round((Convert.ToDecimal(footerItem["CommissionableAmount"].Text) / Convert.ToDecimal(footerItem["NetSalesValue"].Text)) * 100, 2);

//pushes the calculated value to the new footer column
footerItem["CommissionableAmountPercent"].Text = ThePercent.ToString();

0
Eyup
Telerik team
answered on 22 Jul 2019, 10:00 AM
Hello Amanda,

Thank you for sharing your specific approach with your community.

Regards,
Eyup
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
Grid
Asked by
Robert
Top achievements
Rank 1
Answers by
Brian
Top achievements
Rank 1
Marin
Telerik team
Daniel
Top achievements
Rank 1
Pradeep
Top achievements
Rank 1
Eyup
Telerik team
Amanda
Top achievements
Rank 1
Share this question
or