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

Using EF DataSource for one entity plus children

1 Answer 93 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Rayne
Top achievements
Rank 1
Rayne asked on 07 Jul 2011, 04:58 PM
I need to create a report that displays the details (including all children) for a single entity. I've got a method on my Object context that returns a single entity and I'm setting my entity datasource to that method. At runtime, I'd like to set the datasource in code to the current entity (which should already have all the navigation properties loaded, reducing the # of trips to the database). 

I have a few questions:

1. Is it okay that I'm setting the datasource at designtime to a method that requires a parameter, but at runtime I set it to the entity (hence, no parameters needed)?

2. How do I show the details for the child collections? I'm guessing I will need subreports, but I'm not sure how to pass the child collection over. Will I need to use the NeedDataSource event? and if so, how do I use that and will I still be able to design the report using the designer?

3. How do I show/hide data? For example, one of my fields is a boolean value. Based on true or false of this field, I would like to show/hide (collapse) a certain area that displays several other fields. I read on another thread about setting the height of the details, but my data is in a panel (which I couldn't find a height property for).

1 Answer, 1 is accepted

Sort by
0
Peter
Telerik team
answered on 12 Jul 2011, 05:48 PM
Hi Rayne,

Up to your questions:
  1. 1. The EntityDataSource is binding to an ObjectContext and can't bind to a concrete entity. To bind to an arbitrary object you can use the ObjectDataSource component. However the ObjectDataSource component will not be able to provide design time support for the entities. Give it a try and If you still experience any difficulties we will appreciate if you elaborate further on your scenario.
  2. 2. In order to show a detail collection you can utilize report data item such as subreport, table, list or crosstab. To bind the data item to the child collection you can use binding for the report data item's datasource property as shown in the following sample binding:
    Property path  Expression 
     DataSource =Fields.MyCollection 
    3. To hide conditionally report items our suggestion is to use conditional formatting. Generally if you want to keep design time and allow panel item/sections to wrap their content check out the following code snippet:
  3. public partial class Report1: Telerik.Reporting.Report
    {
     
        public Report1()
        {
            //
            // Required for telerik Reporting designer support
            //
            InitializeComponent();
     
            this.panel1.Height = Unit.Pixel(1);
            this.detail.Height = Unit.Pixel(1);
Regards,
Peter
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

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