Sample for Master/Detail using object collection as datasource

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

    Posted 23 Dec 2008 Link to this post

    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.
  2. Hrisi
    Admin
    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:
        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.
  3. DevCraft banner
  4. Elian
    Admin
    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,
    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!

  5. 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"));
  6. 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"));

  7. Peter
    Admin
    Peter avatar
    1611 posts

    Posted 16 Jul 2013 Link to this post

    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.

Back to Top
DevCraft banner