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

Footer, aggregate function and frozen columns bug ?

3 Answers 157 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas LEBRUN
Top achievements
Rank 1
Thomas LEBRUN asked on 02 Sep 2009, 10:00 AM
Hi,

When I used this code to display footer in my application:

 

 

 

private void SetFooter()  
        {  
            var columns = this._Xwg.Columns.Cast<GridViewDataColumn>().Where(c => c.DataType == typeof(double));  
            if (columns.Any())  
            {  
                foreach (var column in columns)  
                {  
                    column.AggregateFunctions.Add(new MaxFunction  
                                                      {  
                                                          FunctionName = "DisplayMaxFunction",  
                                                          Caption = "Max: ",  
                                                          ResultFormatString = "{0:n}",  
                                                          SourceField = FilterSourceField(column.Header.ToString())  
                                                      });  
                    column.AggregateFunctions.Add(new MinFunction  
                                                      {  
                                                          FunctionName = "DisplayMinFunction",  
                                                          Caption = "Min: ",  
                                                          ResultFormatString = "{0:n}",  
                                                          SourceField = FilterSourceField(column.Header.ToString())  
                                                      });  
                    column.AggregateFunctions.Add(new SumFunction  
                                                      {  
                                                          FunctionName = "DisplaySumFunction",  
                                                          Caption = "Sum: ",  
                                                          ResultFormatString = "{0:n}",  
                                                          SourceField = FilterSourceField(column.Header.ToString())  
                                                      });  
                    column.AggregateFunctions.Add(new AverageFunction  
                                                      {  
                                                          FunctionName = "DisplayAverageFunction",  
                                                          Caption = "Average: ",  
                                                          ResultFormatString = "{0:n}",  
                                                          SourceField = FilterSourceField(column.Header.ToString())  
                                                      });  
 
                    _Xwg.CalculateAggregates();  
 
                    // Create the tooltip  
                    var spFunctions = new StackPanel();  
                    spFunctions.Children.Add(new TextBlock { Text = string.Concat(_Xwg.AggregateResults["DisplaySumFunction"].Caption, " ", _Xwg.AggregateResults["DisplaySumFunction"].FormattedValue.ToString()) });  
                    spFunctions.Children.Add(new TextBlock { Text = string.Concat(_Xwg.AggregateResults["DisplayMinFunction"].Caption, " ", _Xwg.AggregateResults["DisplayMinFunction"].FormattedValue.ToString()) });  
                    spFunctions.Children.Add(new TextBlock { Text = string.Concat(_Xwg.AggregateResults["DisplayMaxFunction"].Caption, " ", _Xwg.AggregateResults["DisplayMaxFunction"].FormattedValue.ToString()) });  
                    spFunctions.Children.Add(new TextBlock { Text = string.Concat(_Xwg.AggregateResults["DisplayAverageFunction"].Caption, " ", _Xwg.AggregateResults["DisplayAverageFunction"].FormattedValue.ToString()) });  
 
                    // Create the Textblock for displaying Sum  
                    var tb = new TextBlock  
                                 {  
                                     Text = this._Xwg.AggregateResults["DisplaySumFunction"].FormattedValue.ToString()  
                                 };  
 
                    // Set tooltip  
                    ToolTipService.SetToolTip(tb, spFunctions);  
 
                    // Set the footer  
                    column.Footer = tb;  
 
                    // TODO: Need to find a way to prevent frozen columns to display correct footer (Telerik bug ?)  
                    _Xwg.FrozenColumnCount++;  
                    _Xwg.FrozenColumnCount--;  
                }  
            }  
        } 


It does not work as expected. Indeed, instead of having only the sum results displayed, I have all the results, as shown here:

http://img16.imageshack.us/i/capture1l.png/

But, as soon as I move the bar for the frozen columns, the footer is correctly displayed:

http://img140.imageshack.us/i/capture2e.png/


Is it a bug ? Any workaround ?


Thanks !

3 Answers, 1 is accepted

Sort by
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 03 Sep 2009, 10:38 AM
Nobody got an idea ?


Thanks !
0
Milan
Telerik team
answered on 07 Sep 2009, 03:32 PM
Hi Thomas LEBRUN,

Apparantly there is a problem with the Footer property when it is set in code-behind. We have logged the issue and we will fix it as sonn as possible. Meanwhile you could try defining your aggregates and footer purely in XAML:

<telerik:GridViewDataColumn Header="Number" DataMemberBinding="{Binding Number}">  
    <telerik:GridViewDataColumn.AggregateFunctions> 
        <data:SumFunction Caption="Sum: " ResultFormatString="{}{0:c}" SourceField="Number" /> 
        <data:AverageFunction Caption="Average: " ResultFormatString="{}{0:c}" SourceField="Number" /> 
    </telerik:GridViewDataColumn.AggregateFunctions> 
    <telerik:GridViewDataColumn.Footer> 
        <StackPanel Orientation="Vertical" Margin="5,0">  
            <!-- the number in brackets indicates which function result will be displayed --> 
            <!-- Path=[1] will display the average result --> 
            <TextBlock Text="{Binding Path=[1].FormattedValue}"/>   
        </StackPanel> 
    </telerik:GridViewDataColumn.Footer> 
</telerik:GridViewDataColumn> 

Your Telerik points have been updated.

Best wishes,
Milan
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
Thomas LEBRUN
Top achievements
Rank 1
answered on 07 Sep 2009, 04:05 PM
Hi Milan,

Thanks for your response. I need to use only ocde behind so I'll need to wait for any new version correcting this bug.


Thanks !
Tags
GridView
Asked by
Thomas LEBRUN
Top achievements
Rank 1
Answers by
Thomas LEBRUN
Top achievements
Rank 1
Milan
Telerik team
Share this question
or