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

Need Average of GridCalculatedColumn

2 Answers 108 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rob Diamant
Top achievements
Rank 1
Rob Diamant asked on 05 Mar 2009, 08:59 PM
I am trying to add a footer to my grid. The GridBoundColumns are summed without a problem. However, when I try to get the Average of a GridCalculatedColumn (of averages), it fails on the DataBind with "TargetInvocationException was unhandled by user code", Exception has been thrown by the target of an invocation.

It works if I try the Sum or Max of the averages, but I need the average itself, or the average of the Totals for column 1 and 2.
(btw, what is a Custom GridAggregateFunction?)

Any suggestions?

 

calc1 = New GridCalculatedColumn
calcCol1(0) = "MTD_Used"
calcCol1(1) = "MTD_Available"
With calc1
.HeaderText = "MTD %"
.UniqueName = "MTDP"
.DataFields = calcCol1
.Expression = "{0}/{1}*100"
.HeaderStyle.HorizontalAlign = HorizontalAlign.Right
.HeaderStyle.Wrap = True
.ItemStyle.HorizontalAlign = HorizontalAlign.Right
.DataFormatString = "{0:N2}%"
.Aggregate = GridAggregateFunction.Avg
.FooterAggregateFormatString = "{0:N2}%"
.FooterStyle.HorizontalAlign = WebControls.HorizontalAlign.Right
.FooterStyle.Font.Bold = True
End With
Table1.MasterTableView.Columns.AddAt(3, calc1)

Table1.DataBind()

Using Version 2008.3.1125.35

Rob

 

2 Answers, 1 is accepted

Sort by
0
Yavor
Telerik team
answered on 10 Mar 2009, 08:19 AM
Hello Rob,

Based on the supplied code, it is hard to determine what is causing the exception in question. If the issue persists, you can open a formal support ticket, and send us a small working project, demonstrating your setup, and the unwanted behavior, for additional testing.

Greetings,
Yavor
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Rob Diamant
Top achievements
Rank 1
answered on 11 Mar 2009, 01:48 PM
Never mind, I just manipulated the GridFooterItem to get what I needed.
Tags
Grid
Asked by
Rob Diamant
Top achievements
Rank 1
Answers by
Yavor
Telerik team
Rob Diamant
Top achievements
Rank 1
Share this question
or