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
I managed to run the solution. The grand total doesn't seem to work with your example.
Hi Guys,
I figured out how to add the grand total at the bottom of the row. However, there is another issue that I am having trouble with.
How do i change the bottom footer caption to Grand Total?
Hello,
Glad to hear that.
Are you talking about the Layout.Bands[0].SummaryFooterCaption = "Capt"; ? Please try it out.
UltraGridBand band = ultraGrid1.DisplayLayout.Bands[0]; ultraGrid1.DisplayLayout.Bands[0].Columns["Column 0"].AllowRowSummaries = AllowRowSummaries.True; SummarySettings SumSummary = band.Summaries.Add("Sum " + "Column 0", SummaryType.Sum, band.Columns["Column 0"]); SumSummary.DisplayFormat = "{0:#,##0.00}"; SumSummary.Appearance.TextHAlign = HAlign.Right; SumSummary.SummaryDisplayArea |= SummaryDisplayAreas.Bottom | SummaryDisplayAreas.GroupByRowsFooter; //ultraGrid1.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;
I only want to change the summary foot caption at the bottom of the page(highlighted one) and keep the rest as subtotal. Would you be able to help?
Hi guys,
Any ideas on how to solve the above problem?
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?