Hi ,
I need to add row count to the summaries in the customised grid such that
it should display in the caption the number of rows in the grid as well as if it is filtered
and
In addition to this it needs to preserve the existing caption if any.
Can somebody suggest me .
Thanks,Ashish.
I wasn't able to figure out how to preserve the existing caption, but I think it is just "Summary: x" or "Total: x" or something like that. The following code sample demonstrates how to use the ICustomSummaryCalculator interface to show the number of rows along with the summary value:
this.ultraGrid.DisplayLayout.Override.SummaryDisplayArea = SummaryDisplayAreas.BottomFixed; this.ultraGrid.DisplayLayout.Bands[0].Summaries.Add( SummaryType.Custom, new CustomSummaryCalculator(), this.ultraGrid.DisplayLayout.Bands[0].Columns["UnitsInStock"], SummaryPosition.UseSummaryPositionColumn, this.ultraGrid.DisplayLayout.Bands[0].Columns["UnitsInStock"] );
public class CustomSummaryCalculator : ICustomSummaryCalculator{ private int total = 0;
void ICustomSummaryCalculator.AggregateCustomSummary(SummarySettings summarySettings, UltraGridRow row) { object value = row.Cells[summarySettings.SourceColumn].Value; if ( value is short ) this.total += (short)value; }
void ICustomSummaryCalculator.BeginCustomSummary(SummarySettings summarySettings, RowsCollection rows) { this.total = 0; }
object ICustomSummaryCalculator.EndCustomSummary(SummarySettings summarySettings, RowsCollection rows) { summarySettings.Lines = 2; summarySettings.DisplayFormat = "{0}"; return string.Format("Total: {0}{1}Rows: {2}", this.total, Environment.NewLine, rows.Count); }}
Hi Brian ,
thanks for the solution ...it works great ...
Can you also give a way out to preserve the existing summaries, if any, like ...it should add to the summaries and caption .
Thanks,Ashish