This question is locked. New answers and comments are not allowed.
Fábio Witt jagnow
Top achievements
Rank 2
Fábio Witt jagnow
asked on 09 Nov 2010, 01:13 PM
Hey im using an Aggregate Function in my Grid and its working just nice. What i want is for the totals to display like this:
38:00 (in hours and minutes). I've searched in the forum but didn't found any clue that could help me.
If anybody could help me i'd appreciate.
38:00 (in hours and minutes). I've searched in the forum but didn't found any clue that could help me.
<telerik:GridViewDataColumn.AggregateFunctions> <telerik:SumFunction ResultFormatString="{}{0:G}" SourceField="MyField"/>
</telerik:GridViewDataColumn.AggregateFunctions>If anybody could help me i'd appreciate.
4 Answers, 1 is accepted
0
Hello Fábio Witt jagnow,
What is the type of MyField? DateTime, TimeSpan, Integer, etc.?
All the best,
Yavor Georgiev
the Telerik team
What is the type of MyField? DateTime, TimeSpan, Integer, etc.?
All the best,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Fábio Witt jagnow
Top achievements
Rank 2
answered on 09 Nov 2010, 02:06 PM
Hi my field is nullable decimal.
public Decimal? MyField { get; set; } We use a mask to display that number in hours in the GridViewColumn. I've attached a screen of my issue.
0
Hello Fábio Witt jagnow,
What sort of mask do you use? Can you post some pertinent code? The problem is that the "{0:G}" format string applies to DateTime values, not to decimal. You can check this blog post for more information on string formatting in .NET.
Kind regards,
Yavor Georgiev
the Telerik team
What sort of mask do you use? Can you post some pertinent code? The problem is that the "{0:G}" format string applies to DateTime values, not to decimal. You can check this blog post for more information on string formatting in .NET.
Kind regards,
Yavor Georgiev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Fábio Witt jagnow
Top achievements
Rank 2
answered on 09 Nov 2010, 07:33 PM
Sorry if i made myself not clear, but i've achieved the solution with some more search.
The result format string was there just beacuse i was testing.
I've got what i wanted with Custom Aggregate Function
The example
I'll post my code here just if anyone needs it.
The result format string was there just beacuse i was testing.
I've got what i wanted with Custom Aggregate Function
The example
I'll post my code here just if anyone needs it.
*That tclean.NumToTime is a function that formats a number to time.publicclasstTimeSumFunction : EnumerableSelectorAggregateFunction{protectedoverridestringAggregateMethodName{get{return"TimeSum"; }}protectedoverrideSystem.Type ExtensionMethodsType{get{returntypeof(tTimeSumMethods); }}}publicstaticclasstTimeSumMethods{publicstaticstringTimeSum<T>(IEnumerable<T> source, Func<T, Decimal?> selector){IEnumerable<double> values = from iinsource select Convert.ToDouble(selector(i));returntclean.NumToTime(values.Sum().ToString());}}And there is the picture of the result i wanted.<telerik:GridViewDataColumnBindingPath="MyField"IsReadOnly="True"><telerik:GridViewDataColumn.AggregateFunctions><local:tTimeSumFunctionSourceField="MyField"Caption="Total"/></telerik:GridViewDataColumn.AggregateFunctions></telerik:GridViewDataColumn>