I have several columns that need aggregates functions using the aggregate results of 2 other columns. For instance, column 1's aggregate function needs to take the sum of column 2 and divide it by the sum of column 3. Columns 2 and 3 use the SumFunction...example:
var sumFunction = new SumFunction();
sumFunction.FunctionName = "SumColumn2";
sumFunction.SourceField = "Column2";
col.AggregateFunctions.Add(sumFunction);
...so they are calculated when binding occurs. Therefore, I have to calculate column 1 and put it in my footer AFTER I set my ItemsSource in the datagrid:
_dg.ItemsSource = datalist;
object value = (Convert.ToDouble(_dg.AggregateResults["SumColumn2"].Value) / Convert.ToDouble(_dg.AggregateResults["SumColumn3"].Value)) * 100;
_dg.Columns["Column1"].Footer = String.Format("{0:F2}", value);
This is fine for showing my footer summary. However, my group aggregate footer column is blank since it is part of my GridViewGroupRow...not my Footer. Basically, I can't use this approach anymore since columns 2 and 3 show up fine for my group aggregate footer columns...so I'm assuming for column 1 that I need to create my own custom aggregate function. However, how can I get my custom aggregate function to look at _dg.AggregateResults if they aren't calculated yet? Please let me know the proper way of handling this issue. Thanks in advance. :)
var sumFunction = new SumFunction();
sumFunction.FunctionName = "SumColumn2";
sumFunction.SourceField = "Column2";
col.AggregateFunctions.Add(sumFunction);
...so they are calculated when binding occurs. Therefore, I have to calculate column 1 and put it in my footer AFTER I set my ItemsSource in the datagrid:
_dg.ItemsSource = datalist;
object value = (Convert.ToDouble(_dg.AggregateResults["SumColumn2"].Value) / Convert.ToDouble(_dg.AggregateResults["SumColumn3"].Value)) * 100;
_dg.Columns["Column1"].Footer = String.Format("{0:F2}", value);
This is fine for showing my footer summary. However, my group aggregate footer column is blank since it is part of my GridViewGroupRow...not my Footer. Basically, I can't use this approach anymore since columns 2 and 3 show up fine for my group aggregate footer columns...so I'm assuming for column 1 that I need to create my own custom aggregate function. However, how can I get my custom aggregate function to look at _dg.AggregateResults if they aren't calculated yet? Please let me know the proper way of handling this issue. Thanks in advance. :)