Footer, aggregate function and frozen columns bug ?

4 posts, 0 answers
  1. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 02 Sep 2009 Link to this post

    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 !
  2. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 03 Sep 2009 Link to this post

    Nobody got an idea ?


    Thanks !
  3. DevCraft banner
  4. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 07 Sep 2009 Link to this post

    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.
  5. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 07 Sep 2009 Link to this post

    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 !
Back to Top