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
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.
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!
EDIT: Never mind, I just needed this line:
this.subReport1.Bindings.Add(new Telerik.Reporting.Binding("ReportSource.DataSource", "=ReportItem.DataObject.Departments"));
Where Do I add the following code
this.subReport1.Bindings.Add(new Telerik.Reporting.Binding("ReportSource.DataSource", "=Fields.PriceDataCol1"));
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.
Hi!
Is it possible to have an example for the current version of Telerik Reporting?
Thanks
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 CompanyName, CompanyAddress 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
Hi Silviya,
thanks a lot for your solution!
Best regards
Andrea