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
165
Change the format of the summary value of a column at run time
posted

Dear All,

 

I have a grid bound to a datasource that returns amongst others flying hours in a column called HrsFlown (landing time-take off time). In this column I have minutes flown.

So, needless to say, when one selects the SUM summary it shows the sum of all the minutes flown.

 

Is there a way I can format the end result of the summary field to show hours as minutes ? I am comfy with concatenating the minutes/60 + ":" + minutes %60 , but it seems that the summary column is read only?

 

REgds

 

Paul

 

Parents
  • 53790
    posted

    Hello Paul,

    There are different approaches to solve this task. Maybe you could use ExternalSummary to convert your minutes into Hours + minutes. For example:

    private void ultraGrid1_SummaryValueChanged(object sender, Infragistics.Win.UltraWinGrid.SummaryValueChangedEventArgs e)
    {
        double number;
        if (e.SummaryValue.SummarySettings.SourceColumn.Key == "Duration" && Double.TryParse(e.SummaryValue.Value.ToString(), out number))
        {
            TimeSpan span = System.TimeSpan.FromMinutes(Convert.ToDouble(e.SummaryValue.Value));
            string hours = ((int)span.TotalHours).ToString();
            string minutes = span.Minutes.ToString();
            eArgs.SummaryValue.SetExternalSummaryValue(hours + " h " + minutes + " min");
        }
    }

    private void ultraGrid1_ExternalSummaryValueRequested(object sender, Infragistics.Win.UltraWinGrid.ExternalSummaryValueEventArgs e)
    {
        eArgs = e;
    }

    Please take a look at the attached smaple and video file for more details and let me know if you have any questions

    Regards

  • 53790
    Verified Answer
    posted in reply to Georgi

    Video Part 1

    video_279.part01.rar
Reply Children