Question

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 can't 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:

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.

Was it helpful?

Solution

Seems like you already received an answer to this question from the Telerik forums 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. 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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top