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
I don't understand the request. The code I posted preserves the existing summary by summing the values in the AggregateCustomSummary method.
Requirnment is changed a bit now . We have added a text box at the top which should show this values instaed of summary footer.
So the solution i thought is assigning values to the groupbox on summary changed event , but i dont want to see the summary vaues at the bottom of the grid .If i mark SummaryDisplayArea as None , it doesnt shows up any value as if Summary is not present.
All i need is the total no of rows in the band and filtered rows should be displayed in the text box at every change in griod rows.
Hi Ashish,
Sounds like you are looking for this property:
this.ultraGrid1.Rows.FilteredInRowCount