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

Nested collection in report data source for Grouping expression?

2 Answers 290 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Abhishek
Top achievements
Rank 1
Abhishek asked on 08 Dec 2011, 11:56 PM
Hi,

I'm building a PDF report which has two groups and a detail. I use a custom entity for report data source. However, this entity contains a nested collection. I want to group the outermost group on the "ID" values that are contained in the nested entity collection.

So, my entity looks like:

class ReportEntity
{
...
...
  public List<NestedEntity> Nested { get; set; }
...
...
}

For my report, I set,
ReportEntity repData = .... // Get data from database
Report.DataSource = repData

Now, in designer, I right click on Report, go to "Groups" and create an expression for a group that I've added there. The expression looks like:
=Fields.Nested.ID // Assume ID is a member for NestedEntity class

It throws exception saying "ID" is no defined in current context. I then tried using ObjectDataSource, go to data explorer and drag and drop fields from the data explorer. The expression that designer generated was:
=Fields.Nested.Items.ID

However, when I run the report, I get the exception saying "Items" is not defined in current context.

This issue has been bugging me for a while. While I can assign a collection of NestedEntity directly as Report's data source but I would not prefer to do that. It makes certain other things complex for me given the complexity of the report and data structure.

How can I achieve grouping in this scenario?

[P.S.] I am using Q2 2010

2 Answers, 1 is accepted

Sort by
0
Abhishek
Top achievements
Rank 1
answered on 09 Dec 2011, 06:45 PM
No one? Can someone from telerik help me out here?
0
Elian
Telerik team
answered on 13 Dec 2011, 12:50 PM
Hi Abhishek,

The entity data source gets the whole schema (that's why you see the nested collections in design-time ). However, when retrieving data, it gets the data according to the bindings (it does not get the nested collections). 

So what you should do (since binding is not an option), is to prepare the data (join the tables you need and return flat data). This way you can later create grouping and filtering and will avoid the nesting problem.

Check this article on the topic.

All the best,
Elian
the Telerik team

Q3’11 of Telerik Reporting is available for download. Register for the What's New in Data Tools webinar to see what's new and get a chance to WIN A FREE LICENSE!

Tags
General Discussions
Asked by
Abhishek
Top achievements
Rank 1
Answers by
Abhishek
Top achievements
Rank 1
Elian
Telerik team
Share this question
or