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

Calculations in the Group Header

4 Answers 109 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Reginald
Top achievements
Rank 1
Reginald asked on 04 Aug 2008, 09:27 PM
I am working on a project that handles budgets.  When someone makes a budge adjustment they can have multiple transactions per Account. 

I have created a gridview to display these transactions, this grid is grouped by Account. 

I would like to add the Account total to the group-by expresion, however it would be represented by beginningBalance+Sum(TransactionAmounts) .  Are you able to do this type of calculation in the group header?

4 Answers, 1 is accepted

Sort by
0
Accepted
Jordan
Telerik team
answered on 07 Aug 2008, 07:42 AM
Hello Reginald,

Currently just a single aggregate function can be set to a summary item and not a whole expression.
However, you could try to setup your summary item with a sum aggregate and then in the handler of the GroupSumaryEvaluate event of RadGridView just add the beginningBalance.

Do not hesitate to write if you have more questions.

Best wishes,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Reginald
Top achievements
Rank 1
answered on 07 Aug 2008, 08:04 PM
This worked great.   Below is a sample of the code.

Private Sub radGrid_GroupSumaryEvaluate(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GroupSummaryEvaluationEventArgs) Handles radGrid.GroupSumaryEvaluate
    If e.SummaryItem.FieldName = "Amount" Then
        e.Value = e.Value + e.Group.GetRow(0).Cells("PreviousBalance").Value
    End If
End Sub

0
Reginald
Top achievements
Rank 1
answered on 07 Aug 2008, 08:12 PM
I was able to get the correct value to show; however it doesn't seem to format it.My grouping expression is below :
Sum(Amount) as EndingBalance format ' - Ending Balance: {1:c}' Group By AccountID

I have tried different formating strings also but nothign seems to change the way the value is formated.
0
Jordan
Telerik team
answered on 08 Aug 2008, 12:49 PM
Hello Reginald,

Glad to see that I could help.

Now, regarding you format issue, after some testing I found that this is due to a bug in the summary functionality.
I scheduled this bug to be fixed for the Q2 2008 SP1 release.
And for now, you can easily solve this problem by setting the format string in the GroupSumaryEvaluate handler.

Sincerely yours,
Jordan
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Reginald
Top achievements
Rank 1
Answers by
Jordan
Telerik team
Reginald
Top achievements
Rank 1
Share this question
or