Using external report as a subreport

Stimulsoft Reports.JS discussion
PaPy
Posts: 34
Joined: Fri May 19, 2017 1:51 pm

Using external report as a subreport

Post by PaPy »

Hi,

I want to use a header (maybe a Header.mrt file) for each reports of my customers. If I create 100 reports with this header I want that when I change my header.mrt all my reports with this header gets the header's modification.

I saw that you propose to use some components like "subReport". Have you got a sample project with some reports which use an external report as header for example ?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Using external report as a subreport

Post by Alex K. »

Hello,

You can use the following code to add SubReport to main report:

Code: Select all

var report1 = new Stimulsoft.Report.StiReport();
report1.loadFile("\mainReport.mrt");
var report2 = new Stimulsoft.Report.StiReport();
report2.loadFile("\subReport.mrt");
report1.subReports.add(report2);
Thank you.
PaPy
Posts: 34
Joined: Fri May 19, 2017 1:51 pm

Re: Using external report as a subreport

Post by PaPy »

Hi Aleksey, thanks for your answer.

When I try your code I see my subReport as a second report (on the second page of my main report) only in my viewer. (I can't edit this subReport using designer)

I don't want to add a subReport as a second page of my report. I want to add a report in a part of my main report.

For example I want something like this (see image in attachment).

In our first app we used ReportBuilder. We created report with a custom footer and header for a company. When a logo for a company change for any reason, the company have to change just one file which contains the Header and all the files with this Header get the new logo. In this way, the company do not have to open and change all them reports, they change only one file and all the reports's header get an update. I want to do the same thing with Stimulsoft for our App 2.0.

We just paid your app, I can't use the function "search" in your documentation (https://admin.stimulsoft.com/documentat ... lsoft.html) so it's pretty hard to find how I can do it and I'm loosing a lot of time when I wait an answer through this forum... :(

So please, tell me if you do not understand what I want to do, I will try to be clearer to be more understandable, I really need to do it quickly.

Thanks in advance.
Attachments
I want 100 reports with the same Header but some reports with different footer (my users will choose which footer/header to use and I create the report with the good Header/Footer).
I want 100 reports with the same Header but some reports with different footer (my users will choose which footer/header to use and I create the report with the good Header/Footer).
MyComplexReport.png (21.99 KiB) Viewed 5241 times
PaPy
Posts: 34
Joined: Fri May 19, 2017 1:51 pm

Re: Using external report as a subreport

Post by PaPy »

Up ?
Alex K.
Posts: 6488
Joined: Thu Jul 29, 2010 2:37 am

Re: Using external report as a subreport

Post by Alex K. »

Hello,

In this case, you can use additional SubReports for header and footer or add necessary components from code:
https://www.stimulsoft.com/en/samples/j ... -from-code

Thank you.
schindlergmbh
Posts: 7
Joined: Thu Mar 09, 2017 4:06 pm

Re: Using external report as a subreport

Post by schindlergmbh »

Hi,

I have the same issue.
I have my subreport from a different template (report as xml template string in my case). How can I show this sub template in the subreport component?
Acctually i uses tis code:

report1.subReports.add(report2);

but it is shown as a second page. Not in my subreport component.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Using external report as a subreport

Post by HighAley »

Hello.

There is another solution for you.
You could set the MasterReport for each your report.
The maser report should contain the Header and the Footer.
You could read more in the Report Inheritance > Basic Approaches section of the Programming Manual.

If you want to use external subreport, you should set the subreport in the GetSubReport event.

Code: Select all

        void rep_GetSubReport(object sender, StiGetSubReportEventArgs e)
        {
            StiReport rep = new StiReport();
            rep.LoadFromUrl(@"D:\SubReport.mrt");
            rep.RegData(ds);
            e.Report = rep;
        }
Thank you.
schindlergmbh
Posts: 7
Joined: Thu Mar 09, 2017 4:06 pm

Re: Using external report as a subreport

Post by schindlergmbh »

Hi HighAley,

is there such an event (GetSubReport) in JS?
I can't find it in the Report.JS docs.

Thank you.
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Using external report as a subreport

Post by HighAley »

Hello,

Unfortunately, there is no such event in Reports.JS.
We need to check if it's possible to add this event.

Thank you.

Ticket reference: #5799
HighAley
Posts: 8431
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Using external report as a subreport

Post by HighAley »

Hello.

We have added the GetSubReport event.

Here is a sample:

Code: Select all

report.onGetSubReport = function (e) {
    e.report = new StiReport(); //SubReport
};
Thank you.
Post Reply