Hi,
How do i add grand total to the ultragrid?
I am using the following code but it doesnt seem to show the grand total.
UltraGridBand band = sGridName.DisplayLayout.Bands[0];
sGridName.DisplayLayout.Bands[0].Columns[sColName].AllowRowSummaries =AllowRowSummaries.True;
SummarySettings SumSummary = band.Summaries.Add("Sum " + sColName, SummaryType.Sum, band.Columns[sColName]);
SumSummary.DisplayFormat ="{0:#,##0.00}";
SumSummary.Appearance.TextHAlign =HAlign.Right;
SumSummary.SummaryDisplayArea |=SummaryDisplayAreas.Bottom;
//sGridName.DisplayLayout.Override.SummaryDisplayArea = SummaryDisplayAreas.Bottom;
band.SummaryFooterCaption ="Subtotal:";
band.Override.SummaryFooterCaptionAppearance.FontData.Bold =DefaultableBoolean.True;
band.Override.SummaryFooterCaptionAppearance.BackColor =Color.LightSteelBlue;
band.Override.SummaryFooterCaptionAppearance.ForeColor =Color.Black;
// Here, I want to add grand total
UltraGridColumn columnToSummarize = band.Layout.Bands[0].Columns[sColName];
SummarySettings summary = band.Layout.Bands[0].Summaries.Add("Grand Total For "+sColName, SummaryType.Sum, columnToSummarize);
summary.DisplayFormat ="{0:#,##0.00}";
summary.SummaryDisplayArea |=SummaryDisplayAreas.GroupByRowsFooter;
summary.Appearance.TextHAlign =HAlign.Right;
// Disable grid default highlight
sGridName.DisplayLayout.Override.ResetActiveRowAppearance();
sGridName.DisplayLayout.Override.ResetActiveCellAppearance();
sGridName.DisplayLayout.Override.ActiveAppearancesEnabled =DefaultableBoolean.False;
Thanks
Hello joeleesin,
I tried this and it always works fine for me so I attached my sample to this post for you. Please review it and feel free to let me know if I misunderstood you or if you have any other questions.
I want to see a subtotal by rows and a grand total by that column.
For example:
Column0
- Column1
2
Subtotal: 4
- Column1 2
10
Subtotal: 12Grand Total: 16
Hello,
I've been waiting for a response for about two days now, and still haven't gotten any feedback from you guys yet. I am sorry if I wasn't so clear with my questions , but could someone please help me out resolving the issues that I have encountered?
Thank you for your patience. I have completely misunderstood your scenario. Now I believe that I am on the right track.
I will need some time to examine this behavior by our WinGrid control. So I created the following case for you: "CAS-98400-V8S8X6" where I will let you know of the results.
In the meantime what you could use as a workaround would be to handle to 'AfterExitEditMode' event of the control and use the following line of code:
ultraGrid1.DisplayLayout.RefreshSummaries();
Feel free to let me know if the above suits your needs.
Thank you for using our controls and components. I will update you soon on that matter.
Hi Boris,
RefreshSummaries() fixes my issue.
Thank you so much.
How do I check if the ultragrid AllowRowSummaries is on? I am doing a project where I need to check if the user has turn on the AllowRowSummaries features.
Regards,
Joe
Hi Joe,
AllowRowSummaries just determines if the summary UI is on. The user cannot set this property, it can only be set in code.
It sounds to me like you want to know the user has created any summaries and if so, how to clear them. Is that right? If so, then you do this using the Summaries collection on the band.
You can determine if there are any summaries on the band by checking the count:
this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Count
To clear all the summaries on a band, use the clear method:
this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Clear();
Hi Mike,
I figured it out.
public bool HasAnySummaries(UltraGrid grid) { foreach (UltraGridBand band in grid.DisplayLayout.Bands) { foreach (SummarySettings summarySettings in band.Summaries) { return true; } } return false;
}
And here is what i use to remove:
private void removeRows_Sum(UltraGrid grid,String ColName){ UltraGridBand band = grid.DisplayLayout.Bands[0]; band.Columns[ColName].AllowRowSummaries = AllowRowSummaries.False; SummarySettings tempSettings = band.Summaries[sColName]; band.Summaries.Remove(tempSettings);}
Thank a lot.