This is a migrated thread and some comments may be shown as answers.

Remove aggregates from group header?

1 Answer 82 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Samuel
Top achievements
Rank 1
Samuel asked on 04 Feb 2014, 07:26 PM
Hello, I have a GridView defined in XAML where two columns have the Sum function defined.  To get the totals to show up in the group footer, I had to add the group descriptor in the code behind.  That works fine.  However, the totals are also showing in the group header and I do not want that to happen.  How can I turn those off?


   Public Sub New()
      InitializeComponent()
      Dim gd = New GroupDescriptor With {.Member = "Unit.AdvCd"}
      Me.UnitList.GroupDescriptors.Add(gd)
   End Sub

     <telerik:RadGridView x:Name="UnitList"
                                         Grid.Row="2"
                                         Grid.Column="1"
                                         Margin="5"
                                         HorizontalAlignment="Stretch"
                                         VerticalAlignment="Stretch"
                                         AlternateRowBackground="Gray"
                                         AutoExpandGroups="True"
                                         AutoGenerateColumns="False"
                                         Background="LightGray"
                                         BorderBrush="{StaticResource McpicTealBrush}"
                                         BorderThickness="0"
                                         CanUserDeleteRows="False"
                                         CanUserInsertRows="False"
                                         CanUserSelect="False"
                                         IsReadOnlyBinding="{Binding IsReadOnly}"
                                         ItemsSource="{Binding UnitList}"
                                         RowIndicatorVisibility="Collapsed"
                                         RowLoaded="RadGridView_RowLoaded"
                                         SelectionUnit="FullRow"
                                         ShowColumnFooters="True"
                                         ShowGroupFooters="True"
                                         ShowGroupPanel="False"
                                         telerik:StyleManager.Theme="Expression_Dark">
                        <telerik:RadGridView.SortDescriptors>
                            <telerik:SortDescriptor Member="Unit.UIC" SortDirection="Ascending" />
                        </telerik:RadGridView.SortDescriptors>
                      

                        <telerik:RadGridView.Columns>

                            <telerik:GridViewToggleRowDetailsColumn Width="Auto" />

                            <telerik:GridViewDataColumn Width="Auto"
                                                        DataMemberBinding="{Binding Unit.UIC}"
                                                        Header="UIC"
                                                        HeaderTextAlignment="Center"
                                                        IsFilterable="True"
                                                        IsReadOnly="True"
                                                        IsSortable="True"
                                                        ShowDistinctFilters="True"
                                                        ShowFieldFilters="False"
                                                        SortMemberPath="Unit.UIC" />

                            <telerik:GridViewDataColumn Width="Auto"
                                                        DataMemberBinding="{Binding Unit.AdvCd}"
                                                        Header="MSE"
                                                        HeaderTextAlignment="Center"
                                                        IsFilterable="True"
                                                        IsGroupable="True"
                                                        IsReadOnly="True"
                                                        IsSortable="True"
                                                        ShowDistinctFilters="True"
                                                        ShowFieldFilters="False"
                                                        SortMemberPath="Unit.AdvCd"
                                                        UniqueName="MSE" />

                            <telerik:GridViewDataColumn Width="*"
                                                        DataMemberBinding="{Binding Unit.Name}"
                                                        Header="Name"
                                                        IsFilterable="False"
                                                        IsReadOnly="True"
                                                        IsSortable="True"
                                                        ShowDistinctFilters="False"
                                                        ShowFieldFilters="False"
                                                        SortMemberPath="Unit.Name" />

                            <telerik:GridViewDataColumn Width="Auto"
                                                        DataMemberBinding="{Binding Unit.IsDetachment}"
                                                        Header="Type"
                                                        IsFilterable="True"
                                                        IsReadOnly="True"
                                                        IsSortable="True"
                                                        ShowDistinctFilters="True"
                                                        ShowFieldFilters="False"
                                                        SortMemberPath="Unit.IsDetachment"/>
                                
                            <telerik:GridViewDataColumn Width="Auto"
                                                        DataMemberBinding="{Binding RatedQty}"
                                                        FooterTextAlignment="Right"
                                                        Header="OPFOR Qty"
                                                        IsFilterable="True"
                                                        IsReadOnly="True"
                                                        IsSortable="True"
                                                        ShowDistinctFilters="False"
                                                        ShowFieldFilters="True"
                                                        SortMemberPath="RatedQty"
                                                        TextAlignment="Right"
                                                        UniqueName="RatedQtyColumn">
                                <telerik:GridViewDataColumn.AggregateFunctions>
                                    <telerik:SumFunction />
                                </telerik:GridViewDataColumn.AggregateFunctions>
                            </telerik:GridViewDataColumn>

                            <telerik:GridViewDataColumn Width="Auto"
                                                        DataMemberBinding="{Binding MissionQty}"
                                                        FooterTextAlignment="Right"
                                                        Header="Mission Qty"
                                                        IsFilterable="True"
                                                        IsReadOnly="False"
                                                        IsSortable="True"
                                                        ShowDistinctFilters="False"
                                                        ShowFieldFilters="True"
                                                        SortMemberPath="MissionQty"
                                                        TextAlignment="Right"
                                                        UniqueName="MissionQtyColumn">
                                <telerik:GridViewDataColumn.AggregateFunctions>
                                    <telerik:SumFunction SourceField="MissionQty" />
                                </telerik:GridViewDataColumn.AggregateFunctions>
                                  
                            </telerik:GridViewDataColumn>

                            <telerik:GridViewDataColumn Width="Auto"
                                                        DataMemberBinding="{Binding IsSubmitted}"
                                                        Header="Submitted"
                                                        IsFilterable="True"
                                                        IsReadOnly="True"
                                                        IsSortable="True"
                                                        ShowDistinctFilters="True"
                                                        ShowFieldFilters="False"
                                                        SortMemberPath="IsSubmitted"/>
                              


                        </telerik:RadGridView.Columns>

                    </telerik:RadGridView>

1 Answer, 1 is accepted

Sort by
0
Hristo
Telerik team
answered on 06 Feb 2014, 02:19 PM
Hi Samuel,

You can hide the aggregates from the group header by creating an implicit style targeting GridViewGroupRow. In this style you would have to set the value of the property ShowHeaderAggregates to false. Please see the code snippet as an example:

<Style TargetType="telerik:GridViewGroupRow">
   <Setter Property="ShowHeaderAggregates" Value="False"/>
</Style>

More information on modifying group header can be found in our online documentation on the following link.

Regards,
Hristo
Telerik

Check out the new Telerik Platform - the only modular platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native apps. Register for the free online keynote and webinar to learn more about the Platform on Wednesday, February 12, 2014 at 11:00 a.m. ET (8:00 a.m. PT).

Tags
GridView
Asked by
Samuel
Top achievements
Rank 1
Answers by
Hristo
Telerik team
Share this question
or