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

Sample for Master/Detail using object collection as datasource

8 Answers 479 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 23 Dec 2008, 02:41 PM
Hello,

In the documentation, I've read the part titled "Creating Master-Detail Reports Using SubReports". This is exactly what I need to do, except that the documentation speaks only of working with a SQL database as datasource. In my case, I'm using a list of objects as datasource.

Here is my requirement
I have a List<House> with a variable number of house objects.
Each House object has a Floors property which is a List<Floor> with a variable number of floor objects.
In turn, each Floor has a property Rooms which is a List<Room> with a variable number of room objects.

I need to build a 3 level master-detail report with the following structure :
House 1
some data about House 1
             (repeat for each Floor of house 1)
              some data about FloorX
                     (repeat for each Room of FloorX)
                      some data about RoomY
House 2
some data about House 2
             (repeat for each Floor of house 2)
              some data about FloorX
                     (repeat for each Room of FloorX)
                      some data about RoomY
  ... and so on for each House.

Can you point me to some documentation or sample about how to do that, in the best way possible ?
This is the last element we need to evaluate before validating that we will acquire the product.

8 Answers, 1 is accepted

Sort by
0
Hrisi
Telerik team
answered on 23 Dec 2008, 03:56 PM
Hello John,

Attached you can find example project with nested sub reports in 3 levels using business objects as data. The sample data are:
    Companies
        Departments
            Persons
The names are different but the hierarchy is similar to your request.

The main report is bound to Companies. All sub reports are unbound (DataSource property is not set). We use the NeedDataSource event of the SubReport item to set data for the sub report. Please take a look at how we get the instance of the business objects from the DataRowView.

Please do not hesitate to contact us if you have any other questions.

Best wishes,
Hrisi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Elian
Telerik team
answered on 29 Nov 2011, 05:40 PM
Hello John,

Here is an updated version of the previous sample, using a bit different approach (no code behind, Bindings only).

Best wishes,
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!

0
danparker276
Top achievements
Rank 2
answered on 22 Feb 2013, 02:46 AM
Can you update this for the current reports.  This doesn't display or convert on vs2012 win8.
EDIT:  Never mind, I just needed this line:
            this.subReport1.Bindings.Add(new Telerik.Reporting.Binding("ReportSource.DataSource", "=ReportItem.DataObject.Departments"));
0
Gnaapathy
Top achievements
Rank 1
answered on 11 Jul 2013, 11:09 PM
I am getting the error "An Error has occurred while processing Subreport 'subreport1': Binding Error - Property Datasource does not exist"

Where Do I add the following code

this.subReport1.Bindings.Add(new Telerik.Reporting.Binding("ReportSource.DataSource", "=Fields.PriceDataCol1"));

0
Peter
Telerik team
answered on 16 Jul 2013, 02:05 PM
Hello,

Currently the SubReport.ReportSource is a ReportSource. Thus you can't directly set the DataSource property. Instead if the ReportSource is an InstanceReportSource you can use the following binding:

Property path   Expression
ReportSource.ReportDocument.DataSource  =ReportItem.DataObject

Check out the updated attached sample.

Regards,
Peter
Telerik

Have you tried the new visualization options in Telerik Reporting Q2 2013? You can get them from your account.

0
Andrea
Top achievements
Rank 1
answered on 22 Oct 2018, 07:27 PM

Hi!
Is it possible to have an example for the current version of Telerik Reporting? 
Thanks

Andrea


0
Silviya
Telerik team
answered on 25 Oct 2018, 06:54 AM
Hi Andrea,

Please find the sample project build with the newest version of Telerik Reporting, e.g. R3 2018 SP1 (12.2.18.1017) attached. You might need to run the Upgrade Wizard to upgrade/downgrade the project to the current installed version on the machine.

The Data.cs contains a custom business object Companies having as a properties CompanyNameCompanyAddress and a collection of Departments objects. Every Department has DepartmentName property.

The MainReport.cs uses an ObjectDataSouce component which exposes Companies objects properties and also a list of Departments. We want to display DepartmentName for each Companies object. For the purpose I added a Sub-Report item and created new Binding rule as follows:
Property path: DataSource
Expression: = ReportItem.DataObject.Departments

Regards,
Silviya
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Andrea
Top achievements
Rank 1
answered on 26 Oct 2018, 11:55 AM

Hi Silviya, 
thanks a lot for your solution!

Best regards

Andrea


Tags
General Discussions
Asked by
John
Top achievements
Rank 1
Answers by
Hrisi
Telerik team
Elian
Telerik team
danparker276
Top achievements
Rank 2
Gnaapathy
Top achievements
Rank 1
Peter
Telerik team
Andrea
Top achievements
Rank 1
Silviya
Telerik team
Share this question
or