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

AggregateFunctions and GridViewDataColumn Footer Issue

5 Answers 515 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Glen
Top achievements
Rank 1
Glen asked on 06 Aug 2009, 11:06 PM
Hi,

I am trying to use the AggregateFunctions and display them inside the Footer of the Grid using ItemsControl.ItemTemplate similar to the sample you provide. Though this works fine I have run into a problem, I have a tab control with 2 tabs inside each tab I have a Grid both using AggregateFunctions displayed in the footer using the ItemsControl.ItemTemplate. Initially the footers are displayed fine, if I however move between tabs/grids the footers are displayed empty.

If I do not use the ItemsControl.ItemTemplate approach the footers work fine, if I go and add or update the contents of the grid then the footer is displayed correctly again.

This code does not work:

<telerik:GridViewDataColumn Header="Available Amount" UniqueName="Amount" DataMemberBinding="{Binding Amount}" > 
    <telerik:GridViewDataColumn.AggregateFunctions> 
        <telerik:SumFunction Caption="Sum: " ResultFormatString="{}{0:0}" SourceField="Amount" /> 
        <telerik:AverageFunction Caption="Average: " ResultFormatString="{}{0:0}" SourceField="Amount" /> 
    </telerik:GridViewDataColumn.AggregateFunctions> 
    <telerik:GridViewDataColumn.Footer> 
        <StackPanel Orientation="Vertical" Margin="5,0">  
            <telerik:AggregateResultsList ItemsSource="{Binding}" VerticalAlignment="Center" Grid.Column="4">  
                <ItemsControl.ItemTemplate> 
                    <DataTemplate> 
                        <StackPanel Orientation="Horizontal" VerticalAlignment="Center">  
                            <TextBlock VerticalAlignment="Center" Text="{Binding Caption}" Width="100"/>  
                            <TextBlock VerticalAlignment="Center" Foreground="Blue" Text="{Binding FormattedValue}" /> 
                        </StackPanel> 
                    </DataTemplate> 
                </ItemsControl.ItemTemplate> 
                <ItemsControl.ItemsPanel> 
                    <ItemsPanelTemplate> 
                        <StackPanel Orientation="Vertical" /> 
                    </ItemsPanelTemplate> 
                </ItemsControl.ItemsPanel> 
            </telerik:AggregateResultsList> 
        </StackPanel> 
    </telerik:GridViewDataColumn.Footer> 
</telerik:GridViewDataColumn> 

This code does display but I would really like to control how it is displayed:

<telerik:GridViewDataColumn Header="Available Amount" UniqueName="Amount" DataMemberBinding="{Binding Amount}" > 
    <telerik:GridViewDataColumn.AggregateFunctions> 
        <telerik:SumFunction Caption="Sum: " ResultFormatString="{}{0:0}" SourceField="Amount" /> 
        <telerik:AverageFunction Caption="Average: " ResultFormatString="{}{0:0}" SourceField="Amount" /> 
    </telerik:GridViewDataColumn.AggregateFunctions> 
</telerik:GridViewDataColumn> 

I am using Q2 2009 (Version: 2009.2.701.35)

Hopefully it is something I am missing.

Regards,
Glen

5 Answers, 1 is accepted

Sort by
0
Rossen Hristov
Telerik team
answered on 12 Aug 2009, 07:35 AM
Hello Glen,

I believe that this is a bug that we fixed about a couple of weeks ago (on 27.07.2009). Can you please try with our latest internal build (found in your Client.Net) and see whether the behavior will be the same.

In case the latest internal build does not solve the problem -- please drop us a line and we will investigate the matter.

Kind regards,
Ross
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Glen
Top achievements
Rank 1
answered on 13 Aug 2009, 10:45 PM
Hi,

Thanks for the reply I downloaded the latest release 2009.2 813 and this has fixed the problem.

Glen
0
Saket S
Top achievements
Rank 1
answered on 02 Dec 2009, 06:23 AM
Hi ,

i have to Rounding - up the total/sum present in the footer of Radgrid.
if SUM = 29.61 it will round to Sum = 30
For this functionality is any direct property present?

Thanks in advance.
Ss.
0
Pavel Pavlov
Telerik team
answered on 07 Dec 2009, 05:00 PM
Hello Saket S,

 The aggregate result function has a property called ResultFormatString
For example you may use the following syntax in XAML  :

<telerik:GridViewDataColumn DataMemberBinding="{Binding Balance}" >
        <telerik:GridViewDataColumn.AggregateFunctions>
            <telerik:SumFunction Caption="Sum: " SourceField="Balance" ResultFormatString="{}{0:c}" />
        </telerik:GridViewDataColumn.AggregateFunctions>


All the best,
Pavel Pavlov
the Telerik team


Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Pankaj
Top achievements
Rank 1
answered on 16 Jan 2013, 05:09 AM
   var aggregateFunctionForImpliedCapRate = new AggregateFunction<Salary, decimal?>
            {
                AggregationExpression = adjustedVal =>(decimal?)((adjustedVal.Sum(c=>c.BorrowerNOI))/(adjustedVal.Sum(c=>c.BorrowerShareOfValue)))
                ResultFormatString="{0}{0:F2}"
            };
My result is 0.34234343 and i am trying to use ResultFormatString to display only 2 digits but it throws exception at run time "Input format string not in correct format" .. Any help?

Also is there a way to have aggregate function of a column based on two other aggregate functions of two different columns?

Thanks
Tags
GridView
Asked by
Glen
Top achievements
Rank 1
Answers by
Rossen Hristov
Telerik team
Glen
Top achievements
Rank 1
Saket S
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Pankaj
Top achievements
Rank 1
Share this question
or