I have a grid that has two summary objects. I would like to hide one of these summaries once the grid is grouped on a field (or combintation of fields), and leave the other summary on the grid. Then if the grid is ungrouped show both summaries again.
Is there a way to do this in code, such as in the InitializeGroupByRow event?
Thank you,
T.J.
Hi T.J.,
I beleive SummarySettings has a Visible or hidden property. So hiding the summaries should be easy enough. The tricky part is where to do it. The event you want to use may not be obvious, but grouping is tightly tied to sorting. So the event you want is BeforeSortChange (or maybe AfterSortChange). You can loop through the SortedColumns collection inside this event and check for columns that have IsGroupByColumn set to true to determine if any columns are grouped.
Hi Mike,
unfortunately the SummarySettings hasn't got a Visible or Hidden property. I tried the event "private void gridReport_SummaryValueChanged(object sender, SummaryValueChangedEventArgs e)"
But here again, no possibility to hide a summary.
Have I overlooked something Please help. Thank you!
Oops, sorry about that. Actually, I think this has come up before. I'm not sure why the SummarySettings don't have a Hidden property. So I guess the only way to do it would be to remove the SummarySettings and re-add it.
You should probably submit a feature request to Infragistics to add a Hidden property to the SummarySettings, too. Request a Feature or Component
Sorry for digging this one out, but it seems I have a similar problem right now. That's what I want to do:
I want to have summaries for some columns that are always shown (this works thanks to the SummaryDisplayArea Property).
Additionaly I want to have summaries for columns only if I group by these columns. I have found out that I am able to control that their summaries are only shown in group by columns (again with the SummaryDisplayArea Property). But I don't want to show all summaries if I group by one column - I only want to show the summary to this particular column.
I tried to add and remove the summaries in the AfterSortChange and InitializeGroupByRow events. My CustomSummarizer is instantiated but never uses the AggregateCustomSummary or EndCustomSummary event. Do I have to handle this in an other place?
Thanks for help
I am using Infragistics v8.1
Um, you lost me at the end there. What does adding and removing the summary have to do with the Custom Summary calculator? Are you saying that the methods of the calculator do get called if you don't add the summary dynmically? If that's the case, then something is clearly wrong and you should Submit an incident to Infragistics Developer Support and report it as a bug.
I'll try to explain..
You told before: "So I guess the only way to do it would be to remove the SummarySettings and re-add it." And that's what I tried to do. I add the Summaries for the group by in an event that's thrown when the group by is changed (like AfterSortChanged, BeforeSortChanged, InitializeGroupByRow). I create an object from my CustomSummary class there. But this one never gets called otherwise (e.g. aggregate the rowsand return the result). This is my code:
private void dataGrid_BeforeSortChange(object sender, BeforeSortChangeEventArgs e) { if (this.SampleType == BL_FlexEval.SampleTypes.AllSamples) { SummarySettings summary; foreach (UltraGridColumn col in this.dataGrid.DisplayLayout.Bands[0].SortedColumns) { switch (col.Key.ToUpper()) { case "PRODUCT_ID": if (!this.dataGrid.DisplayLayout.Bands[0].Summaries.Exists("productIdMean")) { SummaryCalculatorMean scm = new SummaryCalculatorMean("sample_mean", "density", "unit", "no_individ"); summary = this.dataGrid.DisplayLayout.Bands[0].Summaries.Add("productIdMean", SummaryType.Custom, scm, this.dataGrid.DisplayLayout.Bands[0].Columns["PRODUCT_ID"], SummaryPosition.UseSummaryPositionColumn, null); this.dataGrid.DisplayLayout.Bands[0].Summaries["productIdMean"].DisplayFormat = GUI_Res.SummaryFooterAvg3; summary.SummaryDisplayArea = SummaryDisplayAreas.HideDataRowFooters | SummaryDisplayAreas.InGroupByRows; } break;
case "AnotherCol":
...
default: break;
} } }
I finally got it working. It seems I had the wrong idea about how the summaries work. Thanks for your help.
Okay... what I am trying to establish is if the two are related.
Do the methods on your custom summary calculator get called if you just add this summary once in the InitializeLayout instead of adding in BeforeSortChange?
Or is it only a problem when you add the summary in BeforeSortChange. You seem to be implying that they are somehow related, which is possible, but seems unlikely. If that is the case, and the custom summary works when added in InitializeLayout but does not work when added in BeforeSortChange, then it's likely bug in the grid, in which case you should Submit an incident to Infragistics Developer Support.
If the summary calculator doesn't work no matter when you add it, then something is probably wrong in your code and I'd have to see more.
Looking at the code, though, it appears that you are adding the summary and positioning it under the column being sorted. Is this column also grouped? If so, then the custom summary calculator probably isn't getting called because the column and therefore the summary, are not visible. Grouped columns are hidden by default. So you would need to use some other column as the SummaryPositionColumn, or maybe align the summary to the left, right, or middle. Or.. you could set HiddenWhenGroupBy on the column to false so it is still displayed even when grouped.