How to merge two StiReports?

Stimulsoft Reports.Flex discussion
Locked
Mike17
Posts: 4
Joined: Tue Mar 08, 2016 2:02 am

How to merge two StiReports?

Post by Mike17 »

Hi, I have a requirement to add all pages from report A to report B. I have found some samples, coded in several languages but flex. None of them work. The steps I have so far are:

1) Create a new StiReport lets call it C.
2) Clear rendered pages.
3) Set its renderd property to true.
4) add all renderedPages from A to C and from B to C.
5) Show report C

Reports C shows one blank page.

reportC = merge(null,reportA);
reportC = merge(reportC,reportB);
reportC.show();

public function mergeRep(finalReport:StiReport, tempReport:StiReport):StiReport{
if (finalReport == null){
finalReport = new StiReport;
finalReport.renderedPages.clear();
finalReport.isRendered = true;
}
for each(var page:StiPage in tempReport.renderedPages) {
page.report = finalReport;
finalReport.renderedPages.add(page);
}
return finalReport;
}
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: How to merge two StiReports?

Post by Vladimir »

Hello Mike,


Please add the following line to your code before show() method:

Code: Select all

reportC.isDocument = true;
reportC.show();
Thank you.
Mike17
Posts: 4
Joined: Tue Mar 08, 2016 2:02 am

Re: How to merge two StiReports?

Post by Mike17 »

Vladimir,

Thanks for your replay. The outcome of adding reportC.isDocument = true, is TWO blank pages instead of one.

BTW
If I show report A or Report B they show correctly.

Report A and Report B are created as follows:

report.loadReportFromByteArray(ba);
report.dictionary.clear();
report.regDataSet("ds1","ds1",ds1);
report.dictionary.synchronize();
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: How to merge two StiReports?

Post by Vladimir »

Hello Mike,

Before merge you should render the reports. Please try to use the following code:

Code: Select all

private function onRenderCompleteA(event: StiReportEvent): void {
	reportB.render();
}

private function onRenderCompleteB(event: StiReportEvent): void {
	// merge to reportC
}

reportA.addEventListener(StiReportEvent.END_RENDER, onRenderCompleteA);
reportB.addEventListener(StiReportEvent.END_RENDER, onRenderCompleteB);

reportA.render();
Thank you.
Mike17
Posts: 4
Joined: Tue Mar 08, 2016 2:02 am

Re: How to merge two StiReports?

Post by Mike17 »

Hi Vladimir,

You are correct!! it works. Now reportC shows two pages, one from reportA and one from reportB, unfortunately the page footer is missing on both pages. Do you know why?

Workarround:
If I call show() instead of render() (keeping the END_RENDER listner to call merge afterwards), reportC has two pages, each one with the correct footer, If I do not call the show method, reportC has two pages without footer.

report.render(); -> Merged report shows pages without page footers.
report.show().close(); -> Merged report shows complete with page footers.

Thank you!!
Vladimir
Posts: 1462
Joined: Fri Apr 13, 2007 4:05 am
Location: Earth

Re: How to merge two StiReports?

Post by Vladimir »

Hello Mike,

We have analyzed the code of the show() method and find a differences only in the following flags:

Code: Select all

reportA.isPageDesigner = false;
reportA.isInteractionRendering = false;
reportA.isRendered = false;
Please try to set these flags before render each report.
If this does not help, please, send us your report template with data, we will analyze it.

Thank you.
Mike17
Posts: 4
Joined: Tue Mar 08, 2016 2:02 am

Re: How to merge two StiReports?

Post by Mike17 »

Vladimir,

You have solved the issue, I have set those flags as you suggested, now the merged report is shown complete with page footers.

Thanks so much for your time and knowledge.

Mike.
Andrew
Posts: 4107
Joined: Fri Jun 09, 2006 3:58 am

Re: How to merge two StiReports?

Post by Andrew »

Hello,

We are glad to help you!

Have a nice day.
Locked