Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
70
create custom summary for wingrid.
posted

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.

  • 69832
    Verified Answer
    Offline posted

    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;
        }

    }