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

Defining a base class for reports

7 Answers 305 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Patrick asked on 30 Dec 2013, 02:04 PM
Hello,
as I have data and processing common to many reports, I am traing to define a base class for a report, like:

type
  MyReport = public abstract class (Telerik.Reporting.Report)
  public
    constructor; empty;
  end;

If I now base a new report on this base class, instead of the standard Telerik Report class, the designer no more works:
The designer could not be shown for this file because none of the classes within it can be designed.
The stack trace is:
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)

What should I do to make this scenario work?

Patrick

7 Answers, 1 is accepted

Sort by
0
Stef
Telerik team
answered on 30 Dec 2013, 03:11 PM
Hello Patrick,

Please take a look at my colleague's suggestion in the following forum thread: Report Inheritance.

I hope this information helps you.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 31 Dec 2013, 02:21 PM
Hello Stef,
it's working but it seems to be more a makeshift job than a real solution.
When I design a window in WPF, it can derive it from Window and work directly in the designer.
Why can't you make something so fundamental work correctly?
Patrick
0
Stef
Telerik team
answered on 31 Dec 2013, 04:19 PM
Hi Patrick,

Good to hear the suggestion works for your requirements.

As discussed in the Report Inheritance forum thread the task is not trivial and would require fundamental changes in the currently existing VS report designer. Notice that behind ordering items and adding data source components there are a lot of services loading and unloading even custom assemblies with external logic.

Notice you can use other approach to display the different content in a SubReport item within the report "frame". For more details take a look at the How to: Create a Master-Detail Report Using a SubReport Item help article.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 31 Dec 2013, 06:18 PM
Hello Stef,
in my case, the use of a base class is to define fields that are common to all reports. For example, I had three reports that work with the same data, but with just different layout. Having a base class avoids to define three times the fields and the processing.
Patrick
0
Stef
Telerik team
answered on 01 Jan 2014, 02:42 PM
Hi Patrick,

It is not clear what is the processing you mentioned that has to be shared between reports, but I believe the scenario can be covered with a Master-Detail layout. where the shared layout and data is placed in the master report, and the difference comes from the loaded sub report. You can pass data to the sub report item from the master report in various way - using report parameters, the ReportItem.DataObject or other custom expression.

Feel free to open a support ticket and send us your details in it, so we can illustrate the above suggestion or advise you accordingly.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

0
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
answered on 01 Jan 2014, 02:47 PM
Hi Stef,
in my case, I need to define common properties and methods to manage the reports, such as a token and a timeout for in memory reports or a save method to save the report in an SQL databse as a PDF document. So a sub-report will not help here.
Patrick
0
Stef
Telerik team
answered on 01 Jan 2014, 03:51 PM
Hi Patrick,

To keep your report definitions easier to maintain, including upgrades, where custom code will have to be manually edited, my suggestion is to build a separate layer handling the save operations regardless the type of report that is passed. This layer can be used in the main application and its methods can be used with any report instance that is passed.
Then inheritance in the reports project will be limited to transferring layout or common report parameters, which can be handled using the approach my colleague suggested in the Report Inheritance forum thread or using Master-Detail scenario.

Regards,
Stef
Telerik

New HTML5/JS REPORT VIEWER with MOBILE AND TOUCH SUPPORT available in Telerik Reporting Q3 2013! Get the new Reporting version from your account or download a trial.

Tags
General Discussions
Asked by
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Stef
Telerik team
Patrick
Top achievements
Rank 2
Iron
Iron
Iron
Share this question
or