Hello!
I have a table with time of call in seconds.
I grouping my table and add a SumFunction.
All works great!
But I need display result of SumFunction like this: HH:MM:SS where HH - hours, MM - minutes and SS - seconds.
Can you tell me how to do it?
I can create inheritance class from SumFunction like this:
But this class properly work only if I have 1 grouping.
If I add another one grouping i have exception (what it was necessary to expect, because format HH:MM:SS SumFunction cant convert to Decimal).
Please, help.
I have a table with time of call in seconds.
I grouping my table and add a SumFunction.
All works great!
But I need display result of SumFunction like this: HH:MM:SS where HH - hours, MM - minutes and SS - seconds.
Can you tell me how to do it?
I can create inheritance class from SumFunction like this:
public class mF : Telerik.Windows.Data.SumFunction |
{ |
public mF() |
{ |
} |
public mF(string propertyName, string calculationField, string caption) |
{ |
base.Name = propertyName; |
base.SourceField = calculationField; |
base.Caption = caption; |
} |
private String GetTime(Decimal totalSeconds) |
{ |
Int32 hours = (Int32)Math.Floor((double)totalSeconds / (double)3600); |
Int32 minutes = (Int32)Math.Floor((double)(totalSeconds - (hours * 3600)) / (double)60); |
Int32 seconds = (Int32)totalSeconds - (hours * 3600) - (minutes * 60); |
return hours.ToString() + ":" + minutes.ToString() + ":" + seconds.ToString(); |
} |
public override Telerik.Windows.Data.AggregateResult Calculate(Telerik.Windows.Data.GroupRecord targetGroup) |
{ |
Telerik.Windows.Data.AggregateResult result = base.Calculate(targetGroup); |
result.Value = GetTime(Convert.ToDecimal(result.Value, System.Globalization.CultureInfo.CurrentCulture)); |
return result; |
} |
} |
If I add another one grouping i have exception (what it was necessary to expect, because format HH:MM:SS SumFunction cant convert to Decimal).
Please, help.