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
Hi guys,
Any ideas on how to solve the above problem?
I believe that I would be able to help you but could you please send me a screenshot which locates the spot where you want to change the caption.
Thank you in advance.
The screenshot was actually two posts above it. Here is another screenshot.
Hi Guys,
The allow row sum in the sub group does not seem to add up correctly. I have attached a screenshot for your review.
First, change the sub group value to 1 and tab out the cell. You will see that the subtotal value stays the same(14) until you collapse the second group.
Do you have any ideas what causes this strange behavior?
Thank you.
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?
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.
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();
Also,
How do I clear AllowRowSummaries?
Thanks,
Joe
Hi Boris,
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,
The only issue that I have left is the summaryfootercaption. I have read about the CreationFilter but still a little confused when it comes to setting the column summary footer caption.
First, I created a class with two methods, BeforeCreateChildElements and AfterCreateChildElements.
I then assigned this class to the grid. My question is, how do i assign SummaryFooterCaption in the AfterCreateChildElements method?