This question is locked. New answers and comments are not allowed.
| 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; |
| } |
| } |
| } |
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 !