Hello,
I'am using UltraGrid (2009.2). I add 6 summeries in my ultragrid. The summeries #1-#5 are displayed as a sum of the columns 1-5 above them. The summary #6 are a sum of all columns. This summary #6 displaying in a new row.
But I want to have a "space" between the first summary row (#1-#5) and the second summary row (#6)..
Also I want to have that each summary row have on the left side a Caption ( i.e. Sum/Week, Total Sum)
COL1 COL2 COL3 COL4 COL5
111 222 333 444 555
Sum/Week : 222 444 666 888 1110
Sum/Total: 3330 (One row space to the row above this row)
I hope it is understandable what I want.
Thanks
Hi,
Elfmanne said:Is it possible to apply Value based appearances to the summery row(s)?
No, but you can use the SummaryValueChanged event on the grid to apply an appearance to the summary based on it's current Value in code.
Mike,
Is it possible to apply Value based appearances to the summery row(s)?
Great example I was able to adapt this rather easily.
Here's some quick sample code I whipped up:
private void ultraGrid1_InitializeLayout(object sender, InitializeLayoutEventArgs e) { UltraGridBand band = e.Layout.Bands[0]; UltraGridColumn column = band.Columns["Column 0"]; SummarySettings summarySettings = band.Summaries.Add( SummaryType.Custom, new LiteralCustomSummaryCalculator("This is my summary"), column, SummaryPosition.UseSummaryPositionColumn, column ); summarySettings.DisplayFormat = "{0}"; column.PerformAutoResize(PerformAutoSizeType.AllRowsInBand); }
internal class LiteralCustomSummaryCalculator : ICustomSummaryCalculator { private string text; public LiteralCustomSummaryCalculator(string text) { this.text = text; } #region ICustomSummaryCalculator Members void ICustomSummaryCalculator.AggregateCustomSummary(SummarySettings summarySettings, UltraGridRow row) { } void ICustomSummaryCalculator.BeginCustomSummary(SummarySettings summarySettings, RowsCollection rows) { } object ICustomSummaryCalculator.EndCustomSummary(SummarySettings summarySettings, RowsCollection rows) { return text; } #endregion }
Okay, so if you already know the value of the summary, then the easiest thing to do is to create an ICustomSummaryCalculator class. All you have to do is return the value, or text, that you want to display in the summary.
When you add the summary to the grid you pass in an instance of your class which implements ICustomSummaryCalculator.