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
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?