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
475
Time formula in summary
posted

I was able to create a summary at the bottom of a column named "Minutes" that adds up all minutes in the parent rows.  My questions is how  to perform the math to show those minutes as hours and minutes?  For example 90 minutes would display as 1:30.

  • 12773
    posted

    Hello,


    I just wanted to know if you were able to solve your issue based on the Brian suggestion or you still need help? Just let me know.
    Thank you.

    Sincerely,
    Dimi
    Developer Support Engineer
    Infragistics, Inc.

  • 69832
    Suggested Answer
    Offline posted

    You could implement the ICustomSummaryCalculator interface and assign that implementation to the SummarySettings.CustomSummaryCalculator property (you must also set the SummarySettings.SummaryType property to 'Custom').

    Example:
    public class CustomSummaryCalculator : ICustomSummaryCalculator
    {
        private int totalMinutes = 0;

        #region ICustomSummaryCalculator Members

        void ICustomSummaryCalculator.AggregateCustomSummary(SummarySettings summarySettings, UltraGridRow row)
        {
            object value = row.Cells[summarySettings.SourceColumn].Value;
            if ( value is int )
            {
                this.totalMinutes += (int)value;
            }
        }

        void ICustomSummaryCalculator.BeginCustomSummary(SummarySettings summarySettings, RowsCollection rows)
        {
            this.totalMinutes = 0;
        }

        object ICustomSummaryCalculator.EndCustomSummary(SummarySettings summarySettings, RowsCollection rows)
        {
            TimeSpan ts = TimeSpan.FromMinutes( this.totalMinutes );
            return string.Format( "{0}:{1}", (int)ts.TotalHours, ts.Minutes );
        }
    }