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?
@kiamhuh
I suggest to use a constructor or a property to the SummaryCalculator class, and pass it a reference to the textbox, but it's a quick and dirty solution.
The best instead is to pass a reference to a class instance that contains the property you need.
Laurent.