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

Group Header Template

1 Answer 643 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Koren
Top achievements
Rank 1
Koren asked on 21 Oct 2011, 05:32 PM
I have a data entry grid that I am grouping by a code in each detail record (by default - the user does not see the grouping panel).  I would like to be able to show some additional data from the group on the header.  To do this I am using Aggregate functions which does display the correct data.  However, I really want to be able to format these results to save some space and make the display more readable.  For example:
00000 Description   Cash  Inv
                                1.00   5.00

What shows is:
00000 Description  Cash 1.00  Inv 5.00

If I leave the aggregate functions showing, I can't seem to format them.  Here is the group descriptor and template that I am trying to use.  What am I missing?  Is there another way to do this?  The data is really parent/child related but the data entry is better for our users if they can go from one "parent' to another so flattened the heirarchy.  This is working fine except the display of the group header.

thanks, Koren
P.S. I realize that the template display may not be exactly right but I can't tweak it until it actually displays something.

<telerik:RadGridView.GroupHeaderTemplate>
                <DataTemplate>
                    <StackPanel Orientation="Horizontal" Margin="0,0">
                        <TextBlock Text="{Binding Group.Key}" Margin="0,0,0,2" Width="200" />                       
                        <telerik:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center">
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <StackPanel Orientation="Vertical" VerticalAlignment="Center">
                                        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Caption}" Width="80" />
                                        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding FormattedValue}" Width="80" />
                                    </StackPanel>
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                            <ItemsControl.ItemsPanel>
                                <ItemsPanelTemplate>
                                    <StackPanel Orientation="Horizontal" />
                                </ItemsPanelTemplate>
                            </ItemsControl.ItemsPanel>
                        </telerik:AggregateResultsList>
                    </StackPanel>
 
                </DataTemplate>
            </telerik:RadGridView.GroupHeaderTemplate>
            <telerik:RadGridView.GroupDescriptors>
                <telerik:GroupDescriptor x:Name="TransactionGroup" Member="TransactionGroup" SortDirection="Ascending" >
                    <telerik:GroupDescriptor.AggregateFunctions>
                        <telerik:MinFunction Caption="Cash: " SourceField="CashTotal" ResultFormatString="{}{0:0.00}"  />
                        <telerik:MinFunction Caption="Inv Beg: " SourceField="BegInvTotal" ResultFormatString="{}{0:0.00}"  />
                        <telerik:MinFunction Caption="End: " SourceField="EndInvTotal" ResultFormatString="{}{0:0.00}"  />
                        <telerik:MinFunction Caption="Acc Beg: " SourceField="BegAccruedTotal" ResultFormatString="{}{0:0.00}"  />
                        <telerik:MinFunction Caption="End: " SourceField="EndAccruedTotal" ResultFormatString="{}{0:0.00}"  />
                        <telerik:MinFunction Caption="Accrual: " SourceField="AccrualAmount" ResultFormatString="{}{0:0.00}"  />
                        <telerik:SumFunction Caption="Ent Amt: " SourceField="Amount" ResultFormatString="{}{0:c2}"  />
                        <local:EnterpriseDifferenceFunction Caption="Diff: " ResultFormatString="{}{0:0.00}" />
                    </telerik:GroupDescriptor.AggregateFunctions>
                </telerik:GroupDescriptor>
            </telerik:RadGridView.GroupDescriptors>


1 Answer, 1 is accepted

Sort by
0
Accepted
Dimitrina
Telerik team
answered on 25 Oct 2011, 02:49 PM
Hello Koren,

You have missed to specify the correct binding for the AggregateResultsList

...<telerik:AggregateResultsList ItemsSource="{Binding AggregateResults}" VerticalAlignment="Center">
<ItemsControl.ItemTemplate>
    <DataTemplate>
  <StackPanel Orientation="Vertical" VerticalAlignment="Center">
 <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding Caption}" Width="80" />     <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center" Text="{Binding FormattedValue}" Width="80" />
</StackPanel>
</DataTemplate>
...
</telerik:AggregateResultsList>

Furthermore, you need to hide the default group header. You could do it like so: 
<telerik:RadGridView.GroupRowStyle>
                <Style TargetType="telerik:GridViewGroupRow">
                    <Setter Property="ShowHeaderAggregates" Value="False"></Setter>
                </Style>
</telerik:RadGridView.GroupRowStyle>

I hope that this is helpful and your problem will be resolved.

 Please try this and share with me how it works.


Best wishes,
Didie
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Koren
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Share this question
or