26 Answers, 1 is accepted
Fortunatelly this is quite possible. A Telerik Report is a .net object defined by a class. You can design the common layout and functionality in a base report class and then inherit it as many times as you need to include the modifications. Furthermore you can modify the report at runtime as it is a .net object.
Hope this helps. Let me know if you have any other questions.
Kind regards,
Chavdar
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
We have prepared a small sample project that demonstrates report inheritance. We have a BaseReport that is the common report that will be inherited. The BaseReport contains a TextBox for a product name and a PictureBox for the product logo. Then we have two reports that inherit it (ProductAReport and ProductBReport) and set the values of the textbox and picturebox accordingly. The textbox and picture box are made protected so that inheriting reports can see them and modify their properties. Please examine the provided sample and if you still have any questions do not hesitate to contact us.
Best wishes,
Ross
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Designing the BaseReport in the designer works as expected. It is when you open an report inheriting BaseReport that problems start occuring. First I left all 3 default sections in BaseReport up, PageHeader, PageFooter and Detail. When opening the InheritingReport in designer you only see what appears to be a single section at top of page. A little playing with it, and you find that all 3 sections are there. Unfortunately those 3 sections are on top of each other. So the problem is that in the InheritingReport all 3 sections ended up at the top obscuring each other.
The interesting part is if you bring the report up in the report viewer it properly lays things out. It is just in the designer it all looks messed up. And it is messed up in a way that makes it unusable for laying out component on the InheritingReport designer.
This is a known issue that is logged in our system for investigation. Unfortunately we have not had the time to research on it yet and it would be left out for a subsequent release.
Sorry for the inconvenience.
All the best,
Steve
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
We need report inheritance, and the designer has to work on the derived reports. Without that, I cannot authorize the purchase of this product. We're impressed with Telerik Reports otherwise, but this is a must-have. Any news of a fix or even an estimated time frame for a fix?
This issue has not been addressed yet and is in our TODO list. Unfortunately we cannot engage with a timeframe at this point, although we would do our best to have it addressed as soon as possible.
All the best,
Steve
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I am experiencing an issue with a table on my derived report. My base class defines my header info, and that is working, however I have a table on the derived report in the details section that comes up blank when I derive from my base report. Once I remove the base derivation and derive from regular Report, my table starts working again. I am not getting any .NET exceptions, and I have walked the code to verify it is indeed setting the datasource to a non-empty dataset.
Any thoughts on why the table in the derived report is not working?
Thanks!
As previously explained, we are aware of the issue. Because of the complexity of the problem we need some more time to find and implement the best solution.
Once again please accept our apologies for the inconvenience and thank you for the understanding and patience.
Best wishes,
Svetoslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Can I ask you how this issue seems like now ?
Best regards
Zbyněk ŠULC
The design time issue of inherited reports still stands. There is no specified time frame and once we start working on this task, it would be duly noted in our Roadmap.
Greetings,
Steve
the Telerik team
I have worked with Telerik Reporting for a couple of weeks now and I have a similar need to be able to derive reports from one base report. I created the report normally. Then I copied it in two new reports, BaseReport and ReportContent. Then I delete everything except PageHeader, ReportHeader and PageFooter from BaseReport and delete everything except GroupHeaders, Details, GroupFooters and ReportFooter from the ReportContent. It must be noticed that not all things can be deleted from the designer, they must be deleted from the designer.cs-file.
Everything works fine. BaseReport preview shows the page headers and footers, and ReportContent preview shows the whole report. If the designer shows something wrong, the cause is probably that there is some duplicate section or other duplicate element in either the base or content reports.
If I want to create a new report, I take a copy of the ReportContent and alter the elements there.
Greetings,
Simo
Any progress from Telerik in the last year??
It would seem pretty basic in the world of reporting to have a "template" to work off of for new reports that have the same basic stuff on every report.
Would it be easier/better to use VS item templates to accomplish this?
Haven't tried it, but does anybody think that would work? Any known issues?
BTW, I have tried the "base class" stuff (without Simo's workarounds) and it would seem fairly unuseable if you need to actually use the designer to customize the derived reports. I mean... that is the point of a "template" right? You want to start with something and then customize. As most have found, the designer of the "derived" report is completely mangled and unrecognizeable. Moreover, if you try to change what is there (only a report header in my case), it basically duplicates everything from the base report into the derived report which causes errors galore.
I really don't understand why you ask to inherit the reports. They are normal CLR types and you can subclass them as you want and they will work. The problem arises when you try to serialize them in xml in order to edit them in our standalone designer. Because your intention is to separate reports - base report and content report, the only possible way to do that is by representing the content as subreport, similar to Master/Detail reports as in our example Invoice report.
Of course you can use VS ItemTeplates, the only overhead is to prepare them. You can use our template in C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\ItemTemplates\CSharp\Reporting\Telerik_Reporting_Q2_2011.zip as example.
For the upcoming release next month, we would introduce templates for the xml reports created via the standalone designer.
Please, consider using base report as main report and every content part realized as subreport.
Greetings,
Hrisi
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
The original post asked about the recommended way to template a report, so the basics of it could be used as a starting point for other derivitive reports. (headers, footers... common things to all reports).
Telerik then responded with creating a base class and inheriting new reports from it as the "way to do it".
A number of people (myself included) responded that the new (inherited from) reports (that use the base class) are unuseable in the designer (main designer... not talking about stand-alone designer). If we can't "design" an inherited report, this whole process is useless.
That was our point.
Creating a VS item template is certainly the way to go with this.
Unless you are building reports in code-only, the item template approach is by far the cleanest way to do this (in my opinion).
Can you please send me the sample code for it ?
Thanks
Vishal
Then there is no problem with the designer, just create a new report and drop the standard header/footer on.
What do others think of this?
Has anyone done it?
Are there any examples of custom report controls especially ones that contain other controls and are resizable etc?
Extending the report items is not possible in terms of using them design-time. What we can recommend is to use a master-detail scenario, where you have a master report which can be extended by the reports contained within SubReport items. Note: SubReports can be used only in the report sections, not in the page sections.
For an example of master-detail scenario, please check our Invoice Report online demo and if you have selected to install our demos you can find the sample report under C:\Program Files (x86)\Telerik\Reporting Q1 2013\Examples (the default installation folder).
If you want to programmatically create some parts of the report, you can dynamically add features to a report object at run-time.
I hope this helps.
Greetings,
Stef
the Telerik team
Have you tried the new visualization options in Telerik Reporting Q1 2013? You can get them from your account.
Needless to say, that would make my life a lot easier as I would be able to manage and maintain those default ReportParameters in one place.
However, when opening the derived report in the VS Report Designer, the parameters from the BaseReport would automatically be added to the Designer.cs file of the derived report, generating a bunch of errors in the report designer, since these ReportParameters already exist.
Today I found this way to work around this issue:
First, implement a BaseReport class inheriting from Telerik.Reporting.Report - see implementation below.
The BaseReport implementation shown here contains an initialization method that must be called after InitializeComponent() in the constructor of your derived report.
That way, the BaseReport will be able to remove any existing parameters (added by the Report Designer’s automatic code generation) before adding the default ones. Since this happens before the Report Designer shows the report, there will be no errors in the Report Designer.
The BaseReport also contains a method for easily getting parameter values, and an example of a property that can be used in code behind in the derived report.
Now you can add a new report or modify an existing one, making it inherit from BaseReport in stead of Telerik.Reporting.Report – while being able to customize the inherited report in the Report Designer.
BaseReport Implementation:
01.
using
System;
02.
using
System.Collections.Generic;
03.
using
System.Configuration;
04.
using
System.Linq;
05.
using
System.Web;
06.
using
Telerik.Reporting;
07.
08.
namespace
MyReporting
09.
{
10.
public
class
BaseReport : Telerik.Reporting.Report
11.
{
12.
/// <summary>
13.
/// Gets the MyStringParameter.
14.
/// </summary>
15.
/// <value>The MyStringParameter.</value>
16.
public
string
MyStringParameter
17.
{
18.
get
19.
{
20.
return
GetParameter<
string
>(
"MyStringParameter"
);
21.
}
22.
}
23.
24.
/// <summary>
25.
/// Initializes a new instance of the <see cref="BaseReport"/> class.
26.
/// </summary>
27.
public
BaseReport()
28.
{
29.
}
30.
31.
/// <summary>
32.
/// Initializes the BaseReport.
33.
/// </summary>
34.
public
virtual
void
InitializeBaseReport()
35.
{
36.
var _parm1 =
new
ReportParameter();
37.
_parm1.Name =
"HiddenStringParam"
;
38.
_parm1.Type = ReportParameterType.String;
39.
_parm1.Value =
"Default value"
;
40.
AddParameter(_parm1);
41.
42.
var _dateFrom =
new
ReportParameter();
43.
_dateFrom.Name =
"DateFrom"
;
44.
_dateFrom.Type = ReportParameterType.DateTime;
45.
_dateFrom.Value = DateTime.Now;
46.
_dateFrom.Text =
"From"
;
47.
_dateFrom.AllowNull =
true
;
48.
_dateFrom.Visible =
true
;
49.
AddParameter(_parm2);
50.
51.
var _dateTo =
new
ReportParameter();
52.
_dateTo.Name =
"DateTo"
;
53.
_dateTo.Type = ReportParameterType.DateTime;
54.
_dateTo.Value = DateTime.Now.AddDays(1);
55.
_dateTo.Text =
"To"
;
56.
_dateTo.AllowNull =
true
;
57.
_dateTo.Visible =
true
;
58.
AddParameter(_dateTo);
59.
}
60.
61.
/// <summary>
62.
/// Adds the parameter, removing any existing matching parameters.
63.
/// </summary>
64.
/// <param name="parm">The parm.</param>
65.
public
void
AddParameter(ReportParameter parm)
66.
{
67.
var index = ReportParameters.IndexOf(parm.Name);
68.
if
(index > -1)
69.
{
70.
ReportParameters.RemoveAt(index);
71.
ReportParameters.Insert(index, parm);
72.
return
;
73.
}
74.
ReportParameters.Add(parm);
75.
}
76.
77.
/// <summary>
78.
/// Gets the parameter value.
79.
/// </summary>
80.
/// <typeparam name="T"></typeparam>
81.
/// <param name="parameterName">Name of the parameter.</param>
82.
/// <returns>T.</returns>
83.
public
T GetParameter<T>(
string
parameterName)
84.
{
85.
return
ReportParameters.Contains(parameterName) ? ReportParameters[parameterName].Value.TypeCastObject<T>() :
default
(T);
86.
}
87.
}
88.
}
Example of derived report constructor:
01.
using
System;
02.
using
System.Linq;
03.
using
System.ComponentModel;
04.
using
System.Drawing;
05.
using
System.Windows.Forms;
06.
using
Telerik.Reporting;
07.
using
Telerik.Reporting.Drawing;
08.
09.
namespace
MyReporting
10.
{
11.
/// <summary>
12.
/// Summary description for DerivedReport.
13.
/// </summary>
14.
public
partial
class
DerivedReport : BaseReport
15.
{
16.
/// <summary>
17.
/// Initializes a new instance of the <see cref="DerivedReport"/> class.
18.
/// </summary>
19.
public
DerivedReport()
20.
{
21.
InitializeComponent();
22.
23.
// Make the BaseReport do its initialization
24.
InitializeBaseReport();
25.
}
26.
}
27.
}
Has the issue with the designer inheriting other reports been resolved?
This is an old post and wanted to double check on if there was an effective patch for inheriting reports.
Thanks!
If the report inherits from a custom class instead of Telerik.Reporting.Report the design-time support for this report in the Visual Studio report designer will be lost.
We recommend to inherit from the default Telerik.Reporting.Report class.
Other approach is to use a SubReport item to change the content of the report while the master report has a base content.
Regards,
Katia
Progress Telerik
Dear Support ,
Could any one help me to make base report and sub report at design time using telerik report designer .
Regards .
Could any one help me to make base report and sub report at design time using telerik report designer .
Regards .
We have answered the same question in the support ticket opened by ids on the topic. For the benefit of our community I will publish the reply also in this thread.
For designing reports you may refer to First Steps articles that demonstrate how to create and set up report. Here are the general steps :
1) Create a report which will be the subreport.
2) Add the report items in it and save it. Note that the page header and page footer of the subreport are not displayed in the main report.
3) Create the main report.
4) Go to Insert -> Subreport .
6) Right click over it -> ReportSource -> URL or file -> Select a file -> navigate to the destination of the report -> OK.
Regards,
Todor
Progress Telerik