Update aggregate functions in custom footer on filter

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

    Posted 03 Sep 2009 Link to this post

    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;  
                    }  
                }  
            } 
    I'm using the following code to set the footer and aggregate functions of columns:

    Now, when I tried to filter my grid, the aggegrate function are not updated ! I've tested to comment this line:

    column.Footer = tb;


    And now, it works fine... S, is there any issues with custom column footer and filter ?



    Thanks !
  2. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 04 Sep 2009 Link to this post

    Any ideas ?


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

    Posted 08 Sep 2009 Link to this post

    Hello Thomas LEBRUN,

    We are currenctly looking into the issue and we will update you on our progress.
    Thanks for reporting this problem.

    Kind regards,
    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. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 10 Sep 2009 Link to this post

    Hello Thomas LEBRUN,

    The problem is that the text of the TextBlock in your footer is set statically in the SetFooter method:

    // Create the Textblock for displaying Sum     
    var tb = new TextBlock  
    {  
        Text = this.playersGrid.AggregateResults["DisplaySumFunction"].FormattedValue.ToString()  
    };  
    column.Footer = tb;  
     

    The solution is to create a binding that will set the text:

    // Create the Textblock for displaying Sum     
    var tb = new TextBlock();  
    Binding binding = new Binding("[0].FormattedValue");  
    binding.Mode = BindingMode.OneWay;  
    tb.SetBinding(TextBlock.TextProperty, binding);  
    column.Footer = tb; 

    That way whenever the aggregate results change the TextBlock will also be updated. You just have to use "[0]" instead of ["DisplaySumFunction"].

    Sincerely yours,
    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.
  6. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 10 Sep 2009 Link to this post

    Hi Milan,

    I will give it a try ASAP.


    Thanks !
  7. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 24 Nov 2009 Link to this post

    Hi Milan,

    I've tried your code but I've encoutered 2 problems:
    - All my column hearders are the same values
    - When I filtered the grid, the columns headers are not updated on the grid (but I can see the in the debugger that the values, in memory, are updated) so it seems to be a display/refresh issue


    any ideas ?


    Thanks !
  8. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 24 Nov 2009 Link to this post

    Please, notice that the bugs (at least the first one) i've mentionned before appears too when I group the results in the grid, as you can see in the pic.


    Thanks.
  9. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 25 Nov 2009 Link to this post

    Nobody got an idea ? This is a quite urgent problem for us because we'll be in production in a few days :)
  10. Thomas LEBRUN
    Thomas LEBRUN avatar
    66 posts
    Member since:
    Sep 2009

    Posted 27 Nov 2009 Link to this post

    FYI, i've tried with the internal build of last week, which has this one the description:

    - Aggregates did not update on filtering

    - Aggregates did not update onedditing

    - GridView.Recalculate aggregates did not force ui to update

    But the problem is still there.....

  11. Milan
    Admin
    Milan avatar
    1989 posts

    Posted 27 Nov 2009 Link to this post

    Hello Thomas LEBRUN,

    We are investigating the update problems with aggregates and will try to resolve the problem as soon as possible. I will report to this thread once we have more information.

    Thank you for your patience.


    Kind regards,
    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.
  12. IdFoods
    IdFoods avatar
    1 posts
    Member since:
    Apr 2015

    Posted 05 Aug 2015 in reply to Milan Link to this post

    Hi,

    We are 2015 and I have the same problem with another version of Telerik, I assumed you don't fix this problem.

    Do you?

  13. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 07 Aug 2015 Link to this post

    Hello,

    I am sorry to hear you experience an issue.

    Would it be possible for you to isolate the case in a demo project and send it to us in a new support ticket? You can also take a look at this blog post for a reference on how to isolate an issue. 

    That way we will check the specific scenario i advice further.

    Regards,
    Dimitrina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
Back to Top
DevCraft banner