RadGrid Aggregation

2 posts, 0 answers
  1. Avo
    Avo avatar
    4 posts
    Member since:
    Oct 2012

    Posted 08 Jul 2015 Link to this post

    Hi,  

    We have a RadGrid control called "RadGrid1" and have it defined as follows in our ASPX page

    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="Both">
    </telerik:RadGrid> 

    In our Vb.Net codebehind, we are using an aggregate function as follows to display the sum in the footer of the grid.

    boundcol(index).Aggregate() = GridAggregateFunction.Sum

    We do not want all the row items to be included in this sum.

    Is there a way to only include the last 2 records in the summation?

    I tried to configure RadGrid1_CustomAggregate using the follow code in the ASPX file

    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="Both" Aggregate="Custom" OnCustomAggregate="RadGrid1_CustomAggregate">
    </telerik:RadGrid> 

    The vb.net file looks like the following for CustomAggregate configuration:

    Protected Sub RadGrid1_CustomAggregate(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridCustomAggregateEventArgs) Handles RadGrid1.CustomAggregate

    End Sub

    However, this event is not being fired.

    I am using Telerik DevCraft version 2013.3 1014

    Please advise how we can only include the last 2 records in the summation.

    Thanks!

    Avo

  2. Radoslav
    Admin
    Radoslav avatar
    1566 posts

    Posted 13 Jul 2015 Link to this post

    Hello Avo,

    Unfortunately the RadGrid does not support build in the desired functionality. However you can achieve it with custom code. On RadGrid.PreRender you can find the last two items in the grid gets their values, sum them and assign the result to the footer item cell. I am sending you a simple example which demonstrates this approach. Please check it out and let me know if it helps you.

    Looking forward for your reply.

    Regards,
    Radoslav
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top