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

Summary Rows

7 Answers 316 Views
GridView
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 24 Aug 2009, 11:00 AM
I need to be able to create a summary column that contains the results of a calculation using other columns in the grid.  I understand that you can set the aggregate function for the summary column to none, however, the summary column requires a field name and does not allow an expression. What is the best way to achieve this functionality?

Thanks,

James

7 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 24 Aug 2009, 11:20 AM
I thought later that I should explain why I need this functionality and can not use a aggregate function for the summary column.  I have a calculated expression column that contains percentages.  An average of this column would not be correct, so I need to be able to perform the same calculation on the summary column that I performed on the calculated expression column at the summary row level using other summary column totals in the expression.

Thanks,

James

0
Julian Benkov
Telerik team
answered on 27 Aug 2009, 01:39 PM
Hi James,

Sorry for delay of answer.

For this scenario you can make a new summary column and use its Expression property for your calculation expression. After that you can apply the summary function for this calculated expression column:

private void radButton1_Click(object sender, EventArgs e) 
    GridViewTextBoxColumn summaryColumn = new GridViewTextBoxColumn("SummaryColumn"); 
    this.radGridView1.Columns.Add(summaryColumn); 
    summaryColumn.Expression = "Count(Country)"
 
    GridViewSummaryRowItem item1 = new GridViewSummaryRowItem(); 
    item1.Add(new GridViewSummaryItem("SummaryColumn""Sum: {0:F2}; ", GridAggregateFunction.Sum)); 
    this.radGridView1.MasterGridViewTemplate.SummaryRowsBottom.Add(item1); 


Regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
James
Top achievements
Rank 1
answered on 09 Sep 2009, 07:11 PM
Julian,

I am still having a problem with the summary column.  Below is an example of what I am trying to do:

 

Dim summaryColumn As New GridViewDecimalColumn("SummaryColumn")  
 
Me.SalesGrid.Columns.Add(summaryColumn)  
 
summaryColumn.Expression = "((Sum(SubTotal) - Sum(Cost)) / Sum(SubTotal)) * 100" 
 
 
 
Dim si7Sales As New GridViewSummaryItem("SummaryColumn", "{0:##0.0}", GridAggregateFunction.First)  
 
Dim srSales As New GridViewSummaryRowItem()  
 
 
 
srSales.Add(si7Sales)  
 
 
 
SalesGrid.MasterGridViewTemplate.SummaryRowsTop.Add(srSales)  
 


I do not need an aggregate function applied to the summary row column.  I want the expression to honor the filtering and grouping applied to the grid.  The above example sums all rows in the grid and does not honor filtering or grouping.  When I try to set the aggregate function to None the summary column is blank. 

Because percentages need to be calculated at the summary level to be correct, and can not be aggregated, how do I modify the above code to populate the summary column correctly and honor filtering and grouping?

Thanks,

James


0
James
Top achievements
Rank 1
answered on 11 Sep 2009, 12:23 PM
Julian,

To be clear, what I need is the GridViewSummaryItem to be able to use an expression using other summary columns in the expression that have already been aggregated and not be required to aggregate the GridViewSummaryItem (GridAggregateFunction.None).

If this is not possible then what work arround do you suggest?

Thanks,

James
0
James
Top achievements
Rank 1
answered on 11 Sep 2009, 12:34 PM
Julian,

Sorry, I meant to say  "what I need is the GridViewSummaryItem to be able to use an expression using other GridViewSummaryItems in the expression that have already been aggregated"

Thanks,

James
0
Julian Benkov
Telerik team
answered on 15 Sep 2009, 06:59 AM
Hello James,

RadGridView currently does not support this functionality. For the next our release we will include built-in expression parser and we will extend the aggregate function calculations and API. Currently, you can calculate expressions in other columns and using the GroupSumaryEvaluate event to calculate and change the value in the desire column.

Kind regards,
Julian Benkov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
James
Top achievements
Rank 1
answered on 16 Sep 2009, 08:54 PM
Julian,

I will wait for the next release.

Thanks,

James
Tags
GridView
Asked by
James
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Julian Benkov
Telerik team
Share this question
or