Within the GridView.CustomSummaryCalculate event handler, it's impossible to access a total summary calculated against another column. The total summary can be obtained within the GridView.CustomDrawFooterCell and GridView.CustomDrawGroupRowFooterCell event handlers. Here, you can obtain a total summary value using the GridSummaryItem.SummaryValue property, and GridView.GetGroupSummaryValue method. For convenience, we suggest that you set the GridGroupSummaryItem.Tag property of group summary items to user friendly values. So, you can use these values to easily obtain a necessary GridGroupSummaryItem from the GridView.GroupSummary collection.
Question Comments
Added By: Gunleif Bjartalid at: 4/7/2013 3:48:23 AM
How can you change the format of calculated value to {0:c2}
now format is 1,40367865433345678789990 - how to make Kr 1,40
Hello Ganleif,
I have created a new ticket on your behalf to discuss this issue: How to change the format of a summary value?. Please bear with us. We will answer your question as soon as possible.
Added By: Volker Niemeyer at: 6/21/2016 3:08:20 AM This solution don't work for me.I have create two Items (Gut and Schlecht) and one item to calculate (Anteil):
Now I wan't to calculate them:[VB.NET]Dim item1 As GridGroupSummaryItem = New GridGroupSummaryItem() item1.FieldName = "Gut" item1.SummaryType = DevExpress.Data.SummaryItemType.Sum item1.DisplayFormat = "{0:#.##} kg" item1.ShowInGroupColumnFooter = .tblReport.Columns("Gut") .tblReport.GroupSummary.Add(item1)Dim item2 As GridGroupSummaryItem = New GridGroupSummaryItem() item2.FieldName = "Schlecht" item2.SummaryType = DevExpress.Data.SummaryItemType.Sum item2.DisplayFormat = "{0:#.##} kg" item2.ShowInGroupColumnFooter = .tblReport.Columns("Schlecht") .tblReport.GroupSummary.Add(item2)Dim item4 As GridGroupSummaryItem = New GridGroupSummaryItem() item4.FieldName = "Anteil" item4.SummaryType = DevExpress.Data.SummaryItemType.Average item4.DisplayFormat = "{0:0.##} %" item4.ShowInGroupColumnFooter = .tblReport.Columns("Anteil") .tblReport.GroupSummary.Add(item4)
[VB.NET]PrivateSub gridView1_CustomDrawRowFooterCell(ByVal sender AsObject, ByVal e As FooterCellCustomDrawEventArgs) Handles tblReport.CustomDrawRowFooterCellIf e.Column.Name = "colAnteil"ThenDim view As GridView = CType(sender, GridView)Try e.Info.DisplayText = Convert.ToDecimal(view.GetGroupSummaryValue(e.RowHandle, CType(view.GroupSummary("Schlecht"), GridGroupSummaryItem))) / Convert.ToDecimal(view.GetGroupSummaryValue(e.RowHandle, CType(view.GroupSummary("Gut"), GridGroupSummaryItem))) * 100Catch ex As Exception MsgBox(Err.Description)EndTryEndIfEndSub
I've got a NULL exception. Can you help?
Regards
Volker
Added By: Sasha (DevExpress Support) at: 6/21/2016 3:42:34 AM
Hello,
I've created a separate ticket on your behalf (T394457: The NullReferenceException occurs in the "How to calculate summary based on the total summary of another column" example). It has been placed in our processing queue and will be answered shortly.