Hi guys.
I wanted to add custom summary at the footer of wingrid, and i want the sum to be divided by 1000.
Please share with to customize the summary.
Thanks.
You have to implement the ICustomSummaryCalculator interface and assing the implementation to the SummarySettings.CustomSummaryCalculator property.
Example:SummarySettings ss = this.ultraGrid1.DisplayLayout.Bands[0].Summaries.Add(SummaryType.Sum, this.ultraGrid1.DisplayLayout.Bands[0].Columns["Summary"]);ss.SummaryType = SummaryType.Custom;ss.CustomSummaryCalculator = new SummaryCalculator();
public class SummaryCalculator : ICustomSummaryCalculator{ private double total = 0;
public void AggregateCustomSummary(SummarySettings settings, UltraGridRow row) { string cellValue = row.Cells[settings.SourceColumn].Text; double val = 0; if ( double.TryParse(cellValue, out val) ) this.total += (val / 1000); }
public void BeginCustomSummary(SummarySettings settings, RowsCollection rows) { this.total = 0; }
public object EndCustomSummary(SummarySettings settings, RowsCollection rows) { return this.total; }
}
I was playing with Brian's code after my job is done.
I could not pass in a textbox value to replace the divisor, is that anyway to do that?
Hi Brian, I was playing with your code after my job is done.
The solution is in a stand alone class, is there any possible way to pass in a textbox value so that the custom summary can be more dynamic?
Hi Brian, your codes work perfectly.
But one more question, how can I change the 'Summary= ....' (at footer) to 'Sum=.....' ???