Hi,
I'm not able to corretly set the custom Format string for GridSummaryColumn on a column of type TimeSpan
I've defined the following custom aggregate:
public class CustomAggregate : ISummaryAggregate
{
public Action<IEnumerable, string, PropertyDescriptor> CalculateAggregateFunc()
{
return (items, property, pd) =>
{
var enumerableItems = items as IEnumerable<NestedPartDTO>;
if (pd.Name == "TotalTime" && enumerableItems != null)
{
TimeSpan ret = TimeSpan.Zero;
foreach (var p in enumerableItems)
if (p.TotalSavedTime.HasValue)
ret = ret + p.TotalSavedTime.Value;
this.TotalTime = ret;
}
};
}
public TimeSpan TotalTime
{
get;
set;
} = TimeSpan.Zero;
}
and I've defined the following GridSummaryColumn:
<Syncfusion:SfDataGrid.TableSummaryRows>
<Syncfusion:GridTableSummaryRow Position="Bottom" ShowSummaryInRow="False">
<Syncfusion:GridSummaryRow.SummaryColumns>
<Syncfusion:GridSummaryColumn Name="TTotalSavedTime" MappingName="TotalSavedTime" CustomAggregate="{StaticResource customAggregate}" SummaryType="Custom" Format="'{TotalTime:h:mm:ss}'"/>
</Syncfusion:GridSummaryRow.SummaryColumns>
</Syncfusion:GridTableSummaryRow>
</Syncfusion:SfDataGrid.TableSummaryRows>
Please refer to the bold text.
If I run this example I obtain a FormatException runtime error.
If I insted remove the bold text I don't have runtime errors and the summay TimeSpan is correctly displayed but without formatting (using the default one).
So, I ask you if can suggest me what's the currect format string to put after "TotalTime:": I'd like to have string such as 1:02:13 (1 hour, 2 minutes, 13 seconds).
Can you hekp me ?