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

Update aggregate functions in custom footer on filter

11 Answers 335 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 03 Sep 2009, 12:30 PM
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 !

11 Answers, 1 is accepted

Sort by
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 04 Sep 2009, 08:25 AM
Any ideas ?


Thanks !
0
Milan
Telerik team
answered on 08 Sep 2009, 09:39 PM
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.
0
Milan
Telerik team
answered on 10 Sep 2009, 11:14 AM
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.
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 10 Sep 2009, 12:43 PM
Hi Milan,

I will give it a try ASAP.


Thanks !
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 24 Nov 2009, 09:14 AM
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 !
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 24 Nov 2009, 03:09 PM
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.
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 25 Nov 2009, 03:49 PM
Nobody got an idea ? This is a quite urgent problem for us because we'll be in production in a few days :)
0
Thomas LEBRUN
Top achievements
Rank 1
answered on 27 Nov 2009, 09:43 AM
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.....

0
Milan
Telerik team
answered on 27 Nov 2009, 02:29 PM
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.
0
IdFoods
Top achievements
Rank 1
answered on 05 Aug 2015, 12:17 PM

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?

0
Dimitrina
Telerik team
answered on 07 Aug 2015, 07:47 AM
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
Tags
GridView
Asked by
Thomas LEBRUN
Top achievements
Rank 1
Answers by
Thomas LEBRUN
Top achievements
Rank 1
Milan
Telerik team
IdFoods
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or