RadGrid, use calculated fields in group and grand footers

9 posts, 0 answers
  1. Robert
    Robert avatar
    1 posts
    Member since:
    May 2012

    Posted 16 May 2012 Link to this post

    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

  2. Brian
    Brian avatar
    1 posts
    Member since:
    Dec 2010

    Posted 16 Aug 2012 Link to this post

    Did anyone ever respond to this inquiry? I have the same question.
  3. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 21 Aug 2012 Link to this post

    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.
  4. Daniel
    Daniel avatar
    1 posts
    Member since:
    Oct 2016

    Posted 11 Oct 2016 in reply to Marin Link to this post

    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.

  5. Marin
    Admin
    Marin avatar
    1057 posts

    Posted 12 Oct 2016 Link to this post

    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.
  6. Pradeep
    Pradeep avatar
    3 posts
    Member since:
    Mar 2014

    Posted 02 Jun 2017 in reply to Marin Link to this post

    Can anyone please post appropriate solution here for aggregating a percentage column?
  7. Eyup
    Admin
    Eyup avatar
    3892 posts

    Posted 07 Jun 2017 Link to this post

    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.
  8. Amanda
    Amanda avatar
    1 posts
    Member since:
    Jul 2019

    Posted 17 Jul 2019 Link to this post

    //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();

  9. Eyup
    Admin
    Eyup avatar
    3892 posts

    Posted 22 Jul 2019 Link to this post

    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.
Back to Top