I can create an IValueConverter class to turn minutes into hours and minutes, but I don't see how to hook it up to the SumFunction for the grid footer.
Is there a way to get this custom formatting in the grid footer? Thanks.
8 Answers, 1 is accepted
You can create your own custom Footer/GroupFooter similar to this demo:
http://demos.telerik.com/silverlight/#GridView/Totals
Sincerely yours,
Vlad
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.
You can declare AggregateResultsList in the footer similar to the posted example and set desired IValueConverter for FormattedValue Binding:
<grid:GridViewDataColumn.Footer>
<StackPanel Orientation="Vertical" Margin="5,0">
<TextBlock Text="Custom footer with aggregates:" Margin="0,0,0,2" />
<gridView:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center">
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center">
<TextBlock VerticalAlignment="Center" Text="{Binding Caption}" />
<TextBlock VerticalAlignment="Center" Text="{Binding FormattedValue}" />
</StackPanel>
</DataTemplate>
</ItemsControl.ItemTemplate>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Vertical" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</gridView:AggregateResultsList>
</StackPanel>
</grid:GridViewDataColumn.Footer>
Sincerely yours,
Vlad
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.
Telerik.Windows.Data.SumFunction f = new Telerik.Windows.Data.SumFunction(); |
f.SourceField = "TotalMinutes"; |
f.Caption = "Total: "; |
f.ResultFormatString = "{0:d}"; |
MyGrid.Columns["TotalMinutes"].AggregateFunctions.Add(f); |
My IValueConverter class is called HourMinuteConverter. Can you tell me how I would implement the converter when setting up the footer dynamically?
In this case it will be better if you create your own custom aggregate function - you can check this demo for more info on how to do this.
Best wishes,
Vlad
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.
Is there any way to call Converter for Footer. i.e. i want to calc grand total of a field who is itself calculated by IValueConverter
here sample code:
<telerik:GridViewDataColumn Width="120" DataMemberBinding="{Binding Path=., Converter={StaticResource ResourceKey=TotalConverter}, Mode=TwoWay}" Header="Total">
<telerik:GridViewDataColumn.Footer>
<StackPanel>
<TextBlock VerticalAlignment="Center" Text="{Binding Path=.,Converter={StaticResource ResourceKey=GrandTotalConverter}, Mode=TwoWay}" />
</StackPanel>
</telerik:GridViewDataColumn.Footer>
</telerik:GridViewDataColumn>
but it is not working.
for my case reference Post is:
http://www.telerik.com/community/forums/wpf/gridview/calculate-grand-total-of-column-which-is-calculated-through-ivalueconverter.aspx
I was able to use an `IValueConverter` in the footer with code like this:
<telerik:GridViewDataColumn Header="Size"
DataMemberBinding="{Binding SizeInBytes, Converter={x:Static local:ByteCountToStringConverter.Instance}}" >
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction/>
</telerik:GridViewDataColumn.AggregateFunctions>
<telerik:GridViewDataColumn.Footer>
<telerik:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center">
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding FormattedValue, Converter={x:Static local:ByteCountToStringConverter.Instance}}" />
</DataTemplate>
</ItemsControl.ItemTemplate>
</telerik:AggregateResultsList>
</telerik:GridViewDataColumn.Footer>
</telerik:GridViewDataColumn>