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

how can I mimic Excel's SUMPRODUCT for my footer?

4 Answers 179 Views
GridView
This is a migrated thread and some comments may be shown as answers.
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

Sort by
0
Veselin Vasilev
Telerik team
answered on 19 May 2010, 07:58 AM
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.
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:

 

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
Veselin Vasilev
Telerik team
answered on 21 May 2010, 03:26 PM
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.
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!  =)
Tags
GridView
Asked by
Brian Graves
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Brian Graves
Top achievements
Rank 1
Share this question
or