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

Access Aggregate Values in roup Header Template

5 Answers 158 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 01 Mar 2012, 05:45 PM
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 !)

5 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 01 Mar 2012, 05:58 PM
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 >>
0
Tony
Top achievements
Rank 1
answered on 01 Mar 2012, 06:18 PM

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
0
Accepted
Pavel Pavlov
Telerik team
answered on 06 Mar 2012, 06:03 PM
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 >>
0
Tony
Top achievements
Rank 1
answered on 08 Mar 2012, 03:19 PM
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?
0
Pavel Pavlov
Telerik team
answered on 08 Mar 2012, 03:54 PM
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 >>
Tags
GridView
Asked by
Tony
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Tony
Top achievements
Rank 1
Share this question
or