I spent some time looking around for info on this and didn't find a good answer as to how to do this without having to use the detailstable databinding and databound events. In all the examples I found they all used the radgrid.MasterTableView.Items collection specifically. My solution turned out to be simpler by using e.Column.Owner.Items from the GridCustomAggregateEventArgs. By checking the e.Owner.Name that is set in the designer properties I can then tell which table that I'm trying to preform the custom Aggregate for and return different results.
In an effort to save others some time here, I'm posting some example code for this.
In an effort to save others some time here, I'm posting some example code for this.
Protected
Sub
rg_CustomAggregate(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCustomAggregateEventArgs)
Handles
rg.CustomAggregate
Dim
i, j, k, l, m, n
As
Integer
For
Each
di
As
GridDataItem
In
e.Column.Owner.Items
If
e.Column.Owner.Name =
"MainTableName"
Then
'preform you custom aggregation calculations
i +=
CType
(di.GetDataKeyValue(
"maintablecolumn1"
),
Integer
)
j +=
CType
(di.GetDataKeyValue(
"maintablecolumn2"
),
Integer
)
k +=
CType
(di.GetDataKeyValue(
"maintablecolumn3"
),
Integer
)
e.Result =
Decimal
.Round(Convert.ToDecimal((i + j) / k * 100), 2)
End
If
If
e.Column.Owner.Name =
"DetailTableName"
Then
l +=
CType
(di.GetDataKeyValue(
"detailtablecolumn1"
),
Integer
)
m +=
CType
(di.GetDataKeyValue(
"detailtablecolumn2"
),
Integer
)
n +=
CType
(di.GetDataKeyValue(
"detailtablecolumn3"
),
Integer
)
e.Result =
Decimal
.Round(Convert.ToDecimal((i + j) / k * 100), 2)
End
If
Next
End
Sub