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

RadGridView Group Header with AggregateFunctions

4 Answers 744 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Benoit
Top achievements
Rank 1
Benoit asked on 14 Apr 2011, 01:55 PM
Hello,

I want to show only one of the Aggregate function define in the columns.

Column One 
         Aggregate define
                   Count
Column Two
        Aggregate define
                    SUM
                    AVERAGE
Column Three
        Aggregate define
                    SUM
                    AVERAGE

In the Group Header I only want the Count Function. Not all aggregates.

Does some one can help me please?

4 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 14 Apr 2011, 02:48 PM
Hello Benoit,

 

I have spent some time to research your case in order to find any way to achieve this result. Regarding the template structure and the internal logic of the GridViewGroupRow you cannot predefine this behavior in such manner. If you take a look at the default template of GridViewGroupRow you can see the element AggregateResulsList, which displays the results of the aggregate functions. This part internally handles the aggregates and there is no way to "instruct" it to display only the first function in the header and to ignore the rest. However you may hide all aggregates by creating a simple style targeted at GridViewGroupRow and set ShowHeaderAggregates property to False, as shown below:
 

<Style TargetType="{x:Type telerik:GridViewGroupRow}">
        <Setter Property="ShowHeaderAggregates" Value="False"/>
</Style>

 

Best wishes,
Vanya Pavlova
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
0
Benoit
Top achievements
Rank 1
answered on 14 Apr 2011, 03:13 PM
Hi Vanya

Thank you for your answer, but it doesn't help me :)

If I don't show all of the aggregate (ShowHeaderAggregates=False) result on the group header. Is it possible to show an aggregate (Items count) without define it in the columns ?

Thank you


0
Vanya Pavlova
Telerik team
answered on 14 Apr 2011, 03:54 PM
Hi Benoit,

 

If the main goal is to just show the total item count in RadgridView in GridViewGroupRow's Header you may predefine it on a RadGridView level and bind a single TextBlock to the count of the items, please refer to the following mark-up:

<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <Grid.Resources>
            <Style x:Key="groupRowStyle" TargetType="telerik:GridViewGroupRow">
                <Setter Property="ShowHeaderAggregates" Value="False"/>
                </Style>
            </Grid.Resources>
        <telerik:RadGridView x:Name="gridView" GroupRowStyle="{StaticResource groupRowStyle}" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.GroupHeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="RadGridView's ItemCount: "/>
                        <TextBlock Text="{Binding Items.Count,ElementName=gridView}"/>
                        </StackPanel>
                    </DataTemplate>
                </telerik:RadGridView.GroupHeaderTemplate>
                <telerik:RadGridView.Columns>
                    <telerik:GridViewDataColumn Header="P1" DataMemberBinding="{Binding Property1,Mode=TwoWay}">
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:CountFunction Caption="Total: "/>
                            </telerik:GridViewDataColumn.AggregateFunctions>
                        </telerik:GridViewDataColumn>
                        <telerik:GridViewDataColumn Header="P1" DataMemberBinding="{Binding Property2,Mode=TwoWay}">
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:CountFunction Caption="Total: "/>
                            </telerik:GridViewDataColumn.AggregateFunctions>
                        </telerik:GridViewDataColumn>
                        <telerik:GridViewDataColumn Header="P1" DataMemberBinding="{Binding Property3,Mode=TwoWay}">
                        <telerik:GridViewDataColumn.AggregateFunctions>
                            <telerik:CountFunction Caption="Total: "/>
                            </telerik:GridViewDataColumn.AggregateFunctions>
                        </telerik:GridViewDataColumn>
                    </telerik:RadGridView.Columns>
            </telerik:RadGridView>
    </Grid>


Please let me know how this works for you!

 

Best wishes,
Vanya Pavlova
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
0
Benoit
Top achievements
Rank 1
answered on 14 Apr 2011, 06:35 PM
Hi Vanya,

Great. But i use the property Group.ItemsCount for items count in group.

Thank You
Tags
GridView
Asked by
Benoit
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Benoit
Top achievements
Rank 1
Share this question
or