I am trying to configure summaries such that they only exist for when the grid is grouped. I do not want a summary row at the end of the grid. I believe I have tried every combination of the SummaryDisplayArea property for a summary as well as on the displaylayout.override as well. I either always get a summary at the end, get no summaries.
Any help would be appreciated.
Thanks,
Dana
Hi Dana,
You can use AfterSortChange event, inside it you can use IsGroupByColumn property of a column and check if it’s a grouped column ,if it is then you can display summaries or hide them as per your requirement by setting the SummaryDisplayAreas to None. Attached is a sample that demonstrates this for you. If you have any questions feel free to contact me.
Sincerely,
Sahaja Kokkalagadda
I am sorry, but I guess I did not make it clear as to what I am trying to accomplish. What I want is summary rows in the footer of each group for the values I have defined summary values for (don't care what field is being grouped by) and I don't ever want a summary row at the bottom of the grid. It seems like you can have a summary row at the bottom of the grid and in the footer of a group, but not just in the footer of the group.
I have attached an annotated screen shot to help clarify what I want to accomplish.
When there are no groups, you can hide the summaries by setting SummaryDisplayArea to None. In the sample we are checking the below condition inside the AfterSort Event which is triggered every time a column is grouped or ungrouped. So if the columns are grouped we set it to required SummaryDisplayArea enum and if the column is not grouped then we set the SummaryDisplayArea to None.
if (bIsGrouped)
this.ultraGrid1.DisplayLayout.Override.SummaryDisplayArea = SummaryDisplayAreas.Bottom;
else
this.ultraGrid1.DisplayLayout.Override.SummaryDisplayArea = SummaryDisplayAreas.None;
Please let me know if you have any other questions.
That does not work if the display areas are defined as part of the summary.
It seems the short of it is that there is not built-in summary definition that says place summaries at the footer of grouped values and no where else. The only way to make it work is to change the location of the summaries in code based on the grouped status of the grid.
Hello dmaxx,
Yes you are correct in that there is no SummaryDisplayAreas for SubTotals only. Sahaja's solution in her first post should still meet your requirements. Set the display area to 'None' when grouped, otherwise set it to 'Default'.
The truth to the matter is there isn't support for this behavior with a single property is because there is no distinction between Grand and Sub totals. It's an all or nothing approach at the moment. I had hoped that the HideDataRowsFooter would hide just the grand totals, but it includes sub totals because summary rows are still considered to be "data rows" no matter what.
I submitted an official product ideas on our website to include something like GroupbyRowsFooterOnly member on the SummaryDisplayAreas enum. I hope you vote for it!
http://ideas.infragistics.com/forums/192359-windows-forms/suggestions/10552467-ultrawingrid-option-to-hide-grand-totals-in-outl
Let me know if you have any questions regarding this matter.
Thanks for submitting the enhancement request. It really is something that is missing. I will definitely vote for it.
As far as the prior suggestion working, it does if the SummaryDisplayArea is defined in the override object only. If it is defined for the specific summaries (which is the case in my application) it does not work. The code has to manipulate the summary values instead. An additional suggestion would be a way override (or make the override actually override) what is defined at the summary level.
In the UltraGrid control, the Override properties are intended to override those sub properties that are not already set or that are set to the default behavior, not to override sub properties that are specifically set. Since in your scenario you are specifically setting the property in a sub property, you would need to then change the SummaryDisplayArea on that level as well.
Below is a snippet that demonstrates how to do that:
foreach (UltraGridColumn col in this.ultraGrid1.DisplayLayout.Bands[0].Columns) { // Determine if any column is grouped if (col.IsGroupByColumn) bIsGrouped = true; //Add the required summaries to specific column. if (!band.Summaries.Exists(col.Header.Caption)) band.Summaries.Add(col.Header.Caption, SummaryType.Sum, col);
// If any column is grouped then Set the SummaryDisplayArea otherwise Set it to None if (bIsGrouped) band.Summaries[col.Header.Caption].SummaryDisplayArea = eArea | e2Area; else band.Summaries[col.Header.Caption].SummaryDisplayArea = SummaryDisplayAreas.None; }
Sincerely,Sahaja Kokkalagadda