New to Telerik UI for WPF? Download free 30-day trial

How to Hide Some Aggregate Results From GroupHeaderRow

Environment

Product RadGridView for WPF and Silverlight

Description

How to hide the aggregate results from the GroupHeaderRow when RadGridView is grouped, and AggregateFunctions are defined.

Solution

  1. Handle the Loaded event of the AggregateResultsList, which shows the aggregate results in the GroupHeaderRow, through an implicit style.

        <!--If the NoXaml binaries are used, the following style needs to be based on the default one, like so:--> 
        <!--<Style TargetType="telerik:AggregateResultsList" BasedOn="{StaticResource AggregateResultsListStyle}">--> 
     
        <Style TargetType="telerik:AggregateResultsList"> 
            <EventSetter Event="Loaded" Handler="AggregateResultsList_Loaded" /> 
        </Style> 
    
  2. Obtain a reference to the AggregateResultsList in the Loaded event and remove items from its ItemsSource.

        private void AggregateResultsList_Loaded(object sender, RoutedEventArgs e) 
        { 
            var aggregateResultsList = sender as Telerik.Windows.Controls.GridView.AggregateResultsList; 
            var itemsSource = (aggregateResultsList.ItemsSource as Telerik.Windows.Data.AggregateResultCollection); 
            if (itemsSource != null && itemsSource.Count > 1) 
            { 
                // You can introduce custom logic here to filter the aggregate results 
                itemsSource.RemoveAt(itemsSource.Count - 1); 
            } 
        } 
    

See Also

In this article