I have pasted this table here to show a loose example of what I'm trying to do. I'm new to Grouping/Summarizing with Infragistics and need some tips.
In the case above there are 2 rows for Comp1 in the accompanying DataTable. The ID and Col1 values are the same for both of these rows. Then they have different values for Col2 as can be seen.
There is a "Total" at the bottom of every row in this Grid that sums Col3 and Col4. Then a Grand Total at the bottom of the Grid that sums these columns for every row.
There could be any number of rows for every Company. There were just 2 in this example. There can even be only 1 but the total will still display.
Any ideas how I should approach this problem?
I've tried adding the Company column to SortedColumns but end up with headers above every row rather than just at the top and I want the Company cells to merge together like is seen with "Comp1" above.
Is what I'm looking for possible? Or something close at least?
Hi Caleb,
In order to get a summary for each company, you would need to group by that company and thus introduce another level in the hierarchy. There's no way to insert a summary into the middle of a rows collection like you have in your mockup here.
Having said that, I think it should be pretty simple to get very close to what you have here. I have attached a small sample project here with a quick attempt to get as close as possible to your mockup.
Actually, I made some decisions that don't exactly match the mockup, but which I thought were better. :)
For example, I put the summaries into the GroupByRow itself, in addition to having them at the bottom of each group. You could turn these off easily enough by removing the InGroupByRows flag from the SummaryDisplayArea property, if you like. In fact, you might want to play around with the various SummaryDisplayArea options, anyway, just to see which one(s) work best for your needs.
And here's the relevant code:
private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { var layout = e.Layout; var band = layout.Bands[0]; var ov = layout.Override; // In order to provide a summary for each company, you need to group by the company. var companyColumn = band.Columns["Company"]; layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy; band.SortedColumns.Add(companyColumn, false, true); // Add a summary for column 3. var column3 = band.Columns["Col3"]; band.Summaries.Add(SummaryType.Sum, column3); // Add a summary for column 4. var column4 = band.Columns["Col4"]; band.Summaries.Add(SummaryType.Sum, column4); ov.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows | // This will give us summaries in the GroupByRow itself SummaryDisplayAreas.BottomFixed | // This will give us a grand total at the bottom. SummaryDisplayAreas.GroupByRowsFooter // This will give us a summary under each GroupByRow ; // Make the summaries in the GroupByRow appears as cells instead of just raw text. ov.GroupBySummaryDisplayStyle = GroupBySummaryDisplayStyle.SummaryCells; }
private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { var layout = e.Layout; var band = layout.Bands[0]; var ov = layout.Override;
// In order to provide a summary for each company, you need to group by the company. var companyColumn = band.Columns["Company"]; layout.ViewStyleBand = ViewStyleBand.OutlookGroupBy; band.SortedColumns.Add(companyColumn, false, true);
// Add a summary for column 3. var column3 = band.Columns["Col3"]; band.Summaries.Add(SummaryType.Sum, column3);
// Add a summary for column 4. var column4 = band.Columns["Col4"]; band.Summaries.Add(SummaryType.Sum, column4);
ov.SummaryDisplayArea = SummaryDisplayAreas.InGroupByRows | // This will give us summaries in the GroupByRow itself SummaryDisplayAreas.BottomFixed | // This will give us a grand total at the bottom. SummaryDisplayAreas.GroupByRowsFooter // This will give us a summary under each GroupByRow ;
// Make the summaries in the GroupByRow appears as cells instead of just raw text. ov.GroupBySummaryDisplayStyle = GroupBySummaryDisplayStyle.SummaryCells; }
InGroupByRows
This is helpful but I'm still having some issues.
Now I have something that looks like this:
I'd post a pic but I don't think I have access to any image sharing services and I cannot simply upload one it seems...
So a few problems here. This is extremely cluttered and hard to read.
Thee CC1C should be vertically centered^
I'll keeping playing with it for now to see what I can find...