I am using AggregateFunctions in GridView, but the function will not recalculate automatically when the data update.
I tried to manually call CalculateAggregates(), but still not working.
I spent a lot of time to search for that, and found that a lot of people have similar problems. But I did't find a good solution.
The only way I know is to use Rebind() after the data updates. I think there should be some better ways.
I created a sample project here. If click the button, it will increase the number by one. If I group it by Position, and click the button, the number data value changes, but the sum value does not.
Could someone help me with it please?
Thanks very much.
<Window x:Class="SampleProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:my="clr-namespace:SampleProject"
Title="MainWindow" Height="700" Width="700">
<Window.Resources>
<my:MyViewModel x:Key="myViewModel"/>
</Window.Resources>
<Grid DataContext="{StaticResource myViewModel}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<telerik:RadGridView Name="playersGrid" Grid.Row="0"
ItemsSource="{Binding Players}"
AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Number}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction SourceField="Number" Caption="Column count: " />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<telerik:RadButton Name="Button1"
Content="Update Data"
Click="Button_Click"
Margin="5"
HorizontalAlignment="Left"/>
</StackPanel>
</Grid>
</Window>
I tried to manually call CalculateAggregates(), but still not working.
I spent a lot of time to search for that, and found that a lot of people have similar problems. But I did't find a good solution.
The only way I know is to use Rebind() after the data updates. I think there should be some better ways.
I created a sample project here. If click the button, it will increase the number by one. If I group it by Position, and click the button, the number data value changes, but the sum value does not.
Could someone help me with it please?
Thanks very much.
<Window x:Class="SampleProject.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
xmlns:my="clr-namespace:SampleProject"
Title="MainWindow" Height="700" Width="700">
<Window.Resources>
<my:MyViewModel x:Key="myViewModel"/>
</Window.Resources>
<Grid DataContext="{StaticResource myViewModel}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<telerik:RadGridView Name="playersGrid" Grid.Row="0"
ItemsSource="{Binding Players}"
AutoGenerateColumns="False">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Name}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Position}"/>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Number}">
<telerik:GridViewDataColumn.AggregateFunctions>
<telerik:SumFunction SourceField="Number" Caption="Column count: " />
</telerik:GridViewDataColumn.AggregateFunctions>
</telerik:GridViewDataColumn>
<telerik:GridViewDataColumn DataMemberBinding="{Binding Country}"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
<StackPanel Grid.Row="1" Orientation="Horizontal">
<telerik:RadButton Name="Button1"
Content="Update Data"
Click="Button_Click"
Margin="5"
HorizontalAlignment="Left"/>
</StackPanel>
</Grid>
</Window>