views:

253

answers:

1

I have a grid that binds a number of child data objects to columns with no issue, using the syntax defined at http://www.telerik.com/help/aspnet-ajax/grdbindingtosubobjects.html.

What I cannot figure out, however, is how to aggregate a child object that is a list or collection. For example, if I have a Customer object and I want to get the customer's first street address, I would use DataField="Customer.Addresses[0].Street" on a standard GridBoundColumn.

How can I get the count of the addresses? I have tried all sorts of GridCalculatedColumn DataFields and Expressions, to no avail. I am looking for something along the lines of this:

<telerik:GridCalculatedColumn DataFields="Customer.Addresses" Expression="Count( Child )" >

That doesn't work, of course. In fact, if I try to do a Count on any dotted data field, I get an exception of "System.Data.SyntaxErrorException: Syntax error in aggregate argument: Expecting a single column argument with possible 'Child' qualifier." For example, just trying to use an expression of "Count({0})" with DataFields set to "Customer.FirstName" (of which there is only one), causes that exception to be thrown at runtime. Doing the same thing with a non-dotted data field, such as SendDate, does not cause the same exception.

A: 

Seems like you already received an answer to this question from the Telerik forums (http://www.telerik.com/community/forums/aspnet-ajax/grid/how-to-bind-a-column-to-a-child-data-object-that-is-a-list.aspx) but for people that might stumble upon this question looking for an answer:

Essentially the RadGrid does not support having Collections in its DataFields, and the supported bindable property types can be found here (http://www.telerik.com/help/aspnet-ajax/grdbindablepropertytypes.html). So in terms of this aggregation you could either do a calculation across this collection before binding it to the RadGrid and have an aggregate column defined, or you could look into using footers much like in this demo.

Also, sorry for not having proper hyperlinks - I can apparently only submit one link per post ;)

Carl B.
I like the idea of doing a calculation on the collection before binding it to the RadGrid, but how do I get that in the aggregate column?
schellack