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

RadGrid Aggregation

1 Answer 212 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Avo
Top achievements
Rank 1
Avo asked on 08 Jul 2015, 08:59 PM

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

1 Answer, 1 is accepted

Sort by
0
Radoslav
Telerik team
answered on 13 Jul 2015, 08:20 AM
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
Tags
Grid
Asked by
Avo
Top achievements
Rank 1
Answers by
Radoslav
Telerik team
Share this question
or