Sample for Master/Detail using object collection as datasource

9 posts, 0 answers
  1. John
    John avatar
    1 posts
    Member since:
    Nov 2008

    Posted 23 Dec 2008 Link to this post


    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.
  2. Hrisi
    Hrisi avatar
    221 posts

    Posted 23 Dec 2008 Link to this post

    Hello John,

    Attached you can find example project with nested sub reports in 3 levels using business objects as data. The sample data are:
    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,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Elian
    Elian avatar
    435 posts

    Posted 29 Nov 2011 Link to this post

    Hello John,

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

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

  4. danparker276
    danparker276 avatar
    389 posts
    Member since:
    Aug 2010

    Posted 21 Feb 2013 Link to this post

    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"));
  5. Gnaapathy
    Gnaapathy avatar
    1 posts
    Member since:
    Jul 2013

    Posted 11 Jul 2013 Link to this post

    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"));

  6. Peter
    Peter avatar
    1665 posts

    Posted 16 Jul 2013 Link to this post


    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.


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

  7. Andrea
    Andrea avatar
    5 posts
    Member since:
    Aug 2016

    Posted 22 Oct 2018 Link to this post

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


  8. Silviya
    Silviya avatar
    417 posts

    Posted 25 Oct 2018 Link to this post

    Hi Andrea,

    Please find the sample project build with the newest version of Telerik Reporting, e.g. R3 2018 SP1 ( 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

    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
  9. Andrea
    Andrea avatar
    5 posts
    Member since:
    Aug 2016

    Posted 26 Oct 2018 in reply to Silviya Link to this post

    Hi Silviya, 
    thanks a lot for your solution!

    Best regards


Back to Top