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

How to display hierarchical collections

2 Answers 424 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Andrija
Top achievements
Rank 1
Andrija asked on 20 Apr 2009, 12:24 PM
Hello All,
Maybe this question was already asked, but I couldn't find proper answer about this.
I have a generic list of some object ( List<Companies> myCompanies ), and Companies class have new collection as a member ( List<Employess> myEmplyes). I have a problem how to display this embedded list of employees. I added subreport, but then I can't pass proper parameters in runtime to subreport.
Can anyone help me?
Thanks,
Andrija

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 23 Apr 2009, 07:44 AM
Hello Andrija,

Here is a forum thread describing similar matters. I've not gone into details in my last post, so here it is:Delivering data for a child subreport can be accomplished in three ways:
  • Using report parameters and filters. For example we define the report parameter ParentID for the child report. Next in the Master report add parameter to the Parameters collection of the SubReport item, e.g. with the same name ParentID and set its value to the field in the Master report data. Now when the master report is processed, SubReport parameters are populated with data and this data is used to update Child report parameters. These parameters can be used to filter the data in the Child report.
  • Using the NeedDataSource event of the SubReport item. This method is appropriate in the case child report is shared between more than one master reports. The child report DataSource should be null, thus signaling the reporting engine to raise NeedDataSource event. Most probably the event handler will reside in the Master report definition class. The handler normally looks as the next code snippet:

    Telerik.Reporting.Processing.SubReport subReportItem = sender as Telerik.Reporting.Processing.SubReport; 
    ParentObj master = (ParentObj)subReportItem.DataObject.RawData; 
    subReportItem.InnerReport.DataSource = master.ChildObj; 
  • Using the NeedDataSource event for the Child report. Maybe this is your case? Again the child report DataSource property should be null. The handler looks like:

    Telerik.Reporting.Processing.Report report= sender as Telerik.Reporting.Processing.Report; 
    Telerik.Reporting.Processing.SubReport subReportItem = report.Parent as Telerik.Reporting.Processing.SubReport; 
    ParentObj master = (ParentObj)subReportItem.DataObject.RawData; 
    report.DataSource = master.ChildObj; 
Please note that we do not discuss how the data is retrieved, only where and how it is assigned to the report's DataSource property.

Hope this information helps.

All the best,
Steve
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Andrija
Top achievements
Rank 1
answered on 23 Apr 2009, 08:26 AM

Thanks for the help that was what I was looking for.
Next time I will try to look more in previous posts.
Regards,
Andrija

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