Brian Graves
Top achievements
Rank 1
Brian Graves
asked on 18 May 2010, 11:15 PM
Excel has a function called SUMPRODUCT which gives the sum of the multiplication of 2 columns. How can I acheive this in my RadGridView column footer?
4 Answers, 1 is accepted
0
Hi Brian Graves,
Yes, this is possible. Please check this blog post for more information and a sample project:
Calculated column in RadGridView for Silverlight + math expressions
All the best,
Veskoni
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
Yes, this is possible. Please check this blog post for more information and a sample project:
Calculated column in RadGridView for Silverlight + math expressions
All the best,
Veskoni
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Graves
Top achievements
Rank 1
answered on 21 May 2010, 03:43 AM
This worked but I had problems adding an Aggregate function to the Total (Converter) column using this code in your solution:
It throws the following exception:
"Invalid property or field - 'Total' for type: Data"
If I change the SourceField to "Count", it works fine...but I want to use the "Total" field which uses the Converter. How can I achieve this?
var sumFunction = new SumFunction();
sumFunction.FunctionName =
"SumPosition";
sumFunction.SourceField =
"Total";
sumFunction.ResultFormatString =
"";
this.gridView.Columns["Total"].AggregateFunctions.Add(sumFunction);
this.gridView.ItemsSource = items;
It throws the following exception:
"Invalid property or field - 'Total' for type: Data"
If I change the SourceField to "Count", it works fine...but I want to use the "Total" field which uses the Converter. How can I achieve this?
0
Hi Brian Graves,
The error is thrown because your datasource does not contain a field called Total.
In this case you need to use custom aggregate functions.
Please find attached the modified project from the blog post which should work as expected.
Note that the recommended approach would be to have a property (Total) in your business object to hold the result of the multiplied properties (Count * Price).
All the best,
Veskoni
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
The error is thrown because your datasource does not contain a field called Total.
In this case you need to use custom aggregate functions.
Please find attached the modified project from the blog post which should work as expected.
Note that the recommended approach would be to have a property (Total) in your business object to hold the result of the multiplied properties (Count * Price).
All the best,
Veskoni
the Telerik team
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 Public Issue Tracking system and vote to affect the priority of the items.
0
Brian Graves
Top achievements
Rank 1
answered on 21 May 2010, 10:45 PM
Thanks. I was able to use your sample in my Silverlight app by modifying the MyTotal() function to take IEnumerable<TSource> since my data source has dynamic types. By using reflection, this worked perfection in my solution! =)