Access Aggregate Values in roup Header Template

6 posts, 1 answers
  1. Tony
    Tony avatar
    24 posts
    Member since:
    Nov 2011

    Posted 01 Mar 2012 Link to this post

    I have my own DataTemplate for displaying a GroupHeader.  I am using aggregates as well. However, I want to customize how the aggregate values are displayed in the group panel. Is there a way to do this? The "ResultFormatString" is insuffcient for what I want to accomplish.

    (Hmm.. wish I could edit my title !)
  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 01 Mar 2012 Link to this post

    Hi Tony,

    What kind of customization are you trying to apply ? Please give me some details so I could point you to the right direction.

    Regards,
    Pavel Pavlov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  3. Tony
    Tony avatar
    24 posts
    Member since:
    Nov 2011

    Posted 01 Mar 2012 Link to this post

    In my custom template for my group header, I have a user control that will display the values from the aggregate functions in a unique way. I basically want to pass /bind the aggregate function results to my user control. Below is my xaml to help communicate what I want.

    Telerik Grid:

    <telerik:RadGridView x:Name="gridPositionGrades" Grid.Row="1"
        DocumentsInTraining}"
        SelectionMode="Single"
        AutoGenerateColumns="False"
        ShowGroupPanel="False"
        GroupHeaderTemplate="{StaticResource Temp}" >
                     
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding DocumentTitle}" Header="Document" >
                <telerik:GridViewDataColumn.AggregateFunctions>
                    <telerik:CountFunction Caption="test" x:Name="Count1"  />
                    <telerik:SumFunction SourceField="Grade" Caption="sum" x:Name="sum" />
                </telerik:GridViewDataColumn.AggregateFunctions>
            </telerik:GridViewDataColumn>
            <telerik:GridViewDataColumn DataMemberBinding="{Binding Grade}" Header="" />
        </telerik:RadGridView.Columns>
        <telerik:RadGridView.GroupDescriptors>
            <telerik:GroupDescriptor Member="PositionCode" SortDirection="Ascending"/>
            <telerik:GroupDescriptor Member="DocumentType" SortDirection="Ascending"/>
            <telerik:GroupDescriptor Member="DocumentCategory" SortDirection="Ascending"/>
        </telerik:RadGridView.GroupDescriptors>
    </telerik:RadGridView>


    The following is where I'm stuck. I want to pass in the aggregate function values to my user control as such:

    <DataTemplate x:Key="Temp">
        <StackPanel Orientation="Horizontal">
            <TextBlock Text="{Binding Group.Key}" />
                <trainingind:TrainingLevelIndicator DisplayType="ALL_TRAINING"
                    Level0Count="{Binding RESULT_OF_AGGREGRATE_FUCTION_FOR_Count1???}"
                    Level1Count="{Binding RESULT_OF_AGGREGRATE_FUCTION_FOR_sum???}"/>
        </StackPanel>
    </DataTemplate>


    Ultimately, I will write my own custom aggregate functions
  4. Answer
    Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 06 Mar 2012 Link to this post

    Hello Tony ,

    I am attaching a small demo illustrating a scenario with a user control placed in the  group header containing a textblock bound to the result of an aggregate function .

    Greetings,
    Pavel Pavlov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
  5. Tony
    Tony avatar
    24 posts
    Member since:
    Nov 2011

    Posted 08 Mar 2012 Link to this post

    Works great.. much simpler than the solution I was coming up with.

    Is there documentation on what other properties are available to me at the group level? That is, what other properties can I access in my XAML when customizing the group row?
  6. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 08 Mar 2012 Link to this post

    Hi Tony ,

    At that level of the visual tree of RadGridView the DataContext is a GroupViewModel. This is a special class designed to expose anything from the group you may need for your bindings.

    Greetings,
    Pavel Pavlov
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top