
Hi,
I want to have a footer in one of my gridview columns that has two rows: one containing a textbox bound to a field in model view, and the second row displays the sum of items in that column.
---------------------------------
Total: {text box}
<sum>
---------------------------------
I have followed the suggestion from another thread to have a style for the footer to set the binding, and then reference that style on the column.
<Style x:Key="SalesTotalStyle" TargetType="telerik:GridViewFooterCell"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Width="75" TextAlignment="Right" FontWeight="Bold" Text="{Binding Path=DataContext.SalesSum, RelativeSource={RelativeSource AncestorType=telerik:GridView}}" /> <TextBox Grid.Row="1" Text="{Binding Path=DataContext.ExpetedSalesTotal, RelativeSource={RelativeSource AncestorType=telerik:GridView}}" Width="75" TextAlignment="Right"/> </Grid> </DataTemplate> </Setter.Value> </Setter> </Style>
This works great and it does display y the data properly in the textbox. However, how can I add an aggregate function in the style section??
I undetstand aggregate functions will not show if the footer is set. I have also tried to create a sum property (SalesSum) that reruns the sum of underlying data, whoever it doesn’t get refreshed in the grid as the user enters items in the column. Any suggestion?
