TypeReportSource and ReportBook

3 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    11 posts
    Member since:
    Apr 2014

    Posted 02 Oct 2014 Link to this post

    Hello,

    I'm designing an application that will produce a number of different reports.  There are three pages for each report and a number of different possible configurations for each page.  There are also completely custom configurations for two of the pages.  I'm storing the name of each custom report in a database and have been able to initialize and display a single report.

    var typeSource = new TypeReportSource();
    typeSource.TypeName = string.Format("Application.ReportLibrary.Custom.{0}, Application.ReportLibrary", myDataObject.CustomReportName);
    typeSource.Parameters.Add("id", _id);

    this.rvMainView.ReportSource = typeSource;
    ...
    ...


    I've also been able to display multiple pages of the standard templates by using a reportbook:

    var rbBookSource = new ReportBook();

    var pageOne = new ReportPageOneType();
    pageOne.Parameters.Clear();
    pageOne.Parameters.Add("id", ReportParameterType.Integer, _id);
    rbBookSource.Reports.Add(pageOne);

    var pageTwo = new ReportPageTwoType();
    pageTwo.Parameters.Clear();
    pageTwo.Parameters.Add("id", ReportParameterType.Integer, _id);
    rbBookSource.Reports.Add(pageOne);

    this.rvMainView.ReportSource = rbBookSource;
    ...

    What I cannot figure out how to do is to merge/combine these two pieces of functionality:

    var rbTypeBook = new ReportBook();

    var p1TypeSource = new TypeReportSource();
    p1TypeSource.TypeName = string.Format("Application.ReportLibrary.Custom.{0}, Application.ReportLibrary", myDataObject.CustomReportPageOneName);
    p1TypeSource.Parameters.Add("id", _id);
    rbTypeBook.Reports.Add(p1TypeSource);

    var p2TypeSource = new TypeReportSource();
    p2TypeSource.TypeName = string.Format("Application.ReportLibrary.Custom.{0}, Application.ReportLibrary", myDataObject.CustomReportPageTwoName);
    p2TypeSource.Parameters.Add("id", _id);
    rbTypeBook.Reports.Add(p2TypeSource);

    this.rvMainView.ReportSource = rbBookSource;
    ...

    Is this possible in any way?

    Thanks.
  2. Nasko
    Admin
    Nasko avatar
    1049 posts

    Posted 07 Oct 2014 Link to this post

    Hello Jonathan,

    When using a Report Book the reports should be added to the ReportBook.Reports collection in the form of report objects. It is not possible to add report sources to the Report Book reports collection.

    Note that you can use the Activator.CreateInstance Method to create a report object after retrieving the report's type name.

    Regards,
    Nasko
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. Jonathan
    Jonathan avatar
    11 posts
    Member since:
    Apr 2014

    Posted 10 Oct 2014 in reply to Nasko Link to this post

    Thank you for the reply, Nasko.

    What I've ended up doing is creating a number of different classes that each inherit from Telerik.Reporting.ReportBook.

    so:

    public class RBClass3 : Telerik.Reporting.ReportBook
    {
        public RBClass3() {
         this.Reports.Add(new ReportTypeOneLayout3());
         this.Reports.Add(new ReportTypeTwoLayout3());
      }
    }

    and then use the TypeReportSource to dynamically instantiate the ReportBook class that I need.
Back to Top