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

TypeReportSource and ReportBook

2 Answers 164 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Jonathan
Top achievements
Rank 1
Jonathan asked on 02 Oct 2014, 07:44 PM
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 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 07 Oct 2014, 01:33 PM
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.

 
0
Jonathan
Top achievements
Rank 1
answered on 10 Oct 2014, 04:09 PM
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.
Tags
General Discussions
Asked by
Jonathan
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Jonathan
Top achievements
Rank 1
Share this question
or