I have a grid that im feeding from an object. Forcing a group by based on an Id. The child rows are being summarized in the group by row.
What i need to do now is at the bottom of the grid create a fixed row that holds The totals of the columns as if they were not grouped or the total of all the summaries displayed in the groupby rows as it should yield the same number either way.
Halp?
Hi,
You can do this using the SummaryDisplayArea property on the override. This is a flagged enum that allows you to specify where the summaries appear. So in this case, you want a summary that is BottomFixed so it shows a grand total. Something like this:
private void ultraGrid1_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs e) { UltraGridLayout layout = e.Layout; UltraGridBand band = layout.Bands[0]; UltraGridOverride ov = layout.Override; layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy; band.SortedColumns.Add("Boolean 1", false, true); band.Summaries.Add(SummaryType.Sum, band.Columns["Int32 1"]); ov.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows | SummaryDisplayAreas.BottomFixed | SummaryDisplayAreas.RootRowsFootersOnly; }
.SortedColumns.Add(Description, False, True) .Summaries.Add(SummaryType.Sum, .Columns(.PayAmount)).DisplayFormat = "${0:N}" .Summaries.Add(SummaryType.Sum, .Columns(Balance)).DisplayFormat = "${0:N}" .Summaries.Add(SummaryType.Sum, .Columns(Discount)).DisplayFormat = "${0:N}" .Summaries.Add(SummaryType.Sum, .Columns(DiscountTaken)).DisplayFormat = "${0:N}" e.Layout.Override.GroupBySummaryDisplayStyle = GroupBySummaryDisplayStyle.SummaryCells e.Layout.Override.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows
The code Above is generating the grid below.: Now if I add another sorted column wont it change the appearance of the current bands? I need a fixed row at the bottom of the grid that will give grand totals. Could you also please clarify the code line:
ov.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows | SummaryDisplayAreas.BottomFixed | SummaryDisplayAreas.RootRowsFootersOnly;Im not entirely sure how pipe delimited properties translate into vb .net
I was not suggesting that you add an additional sorted column. The sample code I posted here is grouping by a single column, just like your grid. I just put that in there to create groups.
You don't need to add any more summaries, either. Again, that line of code was to demonstrate that there is at least one summary in the grid.
All you have to do is set the SummaryDisplayArea. The pipe in C# is equavalent to the 'or' operator in VB.Net.
ov.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows Or SummaryDisplayAreas.BottomFixed Or SummaryDisplayAreas.RootRowsFootersOnly
Apparently I'm the one with the communication problem. I thought you were saying use the Or syntax I thought you meant you could use one or the other. Working perfectly. Think I owe you a Beer too.
Yeah, it's a little weird. When you 'Or' the items together it's like adding them together. You would think that 'And' would be the right thing to do, but 'And' is actually mutually exclusive. It's just one of those quirks of the English language and boolean arithmetic. :)