Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
How to show Group Summary in the Group Header?
posted

Hi,

 I'd like to be able to include group totals in the group headers of WebGrid. I have a webgrid which has an amount column. As the user's group the columns I'd like to sum the group amount column and show it in the header. I'm able to show total's in the footer for the last grouped column but not for the upper groupped columns. Here's a sample code;

Protected Sub UltraWebGrid1_DataBound(ByVal sender As Object, ByVal e As System.EventArgs) Handles UltraWebGrid1.DataBound
UltraWebGrid1.ExpandAll(True)
End Sub

Protected Sub UltraWebGrid1_InitializeGroupByRow(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.RowEventArgs) Handles UltraWebGrid1.InitializeGroupByRow

'UltraWebGrid1.DisplayLayout.GroupByRowDescriptionMaskDefault = "Value: [value]" This is where I think I need to add the each grouped header total value.

End SubProtected Sub UltraWebGrid1_InitializeLayout(ByVal sender As Object, ByVal e As Infragistics.WebUI.UltraWebGrid.LayoutEventArgs) Handles UltraWebGrid1.InitializeLayout

UltraWebGrid1.Columns(0).IsGroupByColumn = True

UltraWebGrid1.Columns(0).AllowGroupBy = AllowGroupBy.Yes

UltraWebGrid1.Columns(1).IsGroupByColumn = True

UltraWebGrid1.Columns(1).AllowGroupBy = AllowGroupBy.Yes

Dim b As UltraGridBand = UltraWebGrid1.Bands(0)

b.ColFootersVisible = ShowMarginInfo.Yes

e.Layout.Bands(0).Columns(0).FooterText = "dummy footer text - never appears"

Dim c As Infragistics.WebUI.UltraWebGrid.UltraGridColumn = e.Layout.Bands(0).Columns.FromKey("Total")

c.DataType = "System.Double"

c.Format = "C"

c.CellStyle.HorizontalAlign = HorizontalAlign.Right

' set up footer summaries for total column

c.Footer.Key = "Total"

'c.Footer.Caption = "Total = "

c.Footer.Total = Infragistics.WebUI.UltraWebGrid.SummaryInfo.Sum

c.Footer.Formula = "ROUND(SUM([Total]),2)"

End Sub

 

Thanks.