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

Retrieving Aggrate Values to Place in Chart

4 Answers 63 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 16 Aug 2010, 07:50 PM
Currently, I have a simple RadGridView which shows a list of suppliers, part number, and purchase price. I'm grouping the information by the supplier and aggregating the purchase price so the user can see the purchase price by supplier. Is there a way to get the aggregate totals from the grid so that I can show them in a chart?

4 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 17 Aug 2010, 07:52 AM
Hi Thomas,

You can get the Aggregate Results for a certain group using the GetAggregateResults method. For example, if you are using the Grouping event for taking the results, you may proceed as follows:

void playersGrid_Grouping(object sender, GridViewGroupingEventArgs e)
{          
this.groupView.GroupDescriptors.Add(e.GroupDescriptor);
var firstGroup = this.groupView.Groups[0] as AggregateFunctionsGroup;
var result = firstGroup.GetAggregateResults(e.GroupDescriptor.AggregateFunctions);
 
MessageBox.Show("Result of the aggregate function for the first group is: " + result[0].ToString());
}


Regards,
Maya
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
Thomas
Top achievements
Rank 1
answered on 17 Aug 2010, 06:42 PM
Thanks!

I do have one last question, what is the data type for this.groupView?
0
Accepted
Maya
Telerik team
answered on 18 Aug 2010, 07:29 AM
Hi Thomas,

The "groupView" is of type QueryableCollectionView. I am sending you a sample project implementing the idea of retrieving the aggregate values. 
 

Greetings,
Maya
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
Thomas
Top achievements
Rank 1
answered on 18 Aug 2010, 05:32 PM
That is what I thought. Thanks! It works perfectly!
Tags
GridView
Asked by
Thomas
Top achievements
Rank 1
Answers by
Maya
Telerik team
Thomas
Top achievements
Rank 1
Share this question
or