Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » BIRT » How to change style of Repeated Header
How to change style of Repeated Header [message #1001393] Wed, 16 January 2013 11:18 Go to next message
Ann Black-Ziegelbein is currently offline Ann Black-Ziegelbein
Messages: 5
Registered: June 2012
Junior Member
Hello! I am developing a birt report which has a table, with groups that spans multiple pages. My group header is repeated when it spans page breaks (which is what I would like for it to do.) I would like to have a mechanism to visually indicate, though, that the group's details have span multiple pages by changing the background of the group header to a new style, or add in the words "Continued" to the header content. I have tried to do this via scripting, however it appears that the onCreate and onRender script hooks are called just once for the header - irrespective of how many times will be repeated? I am rendering a PDF document. Is there a mechanism for me to change the style of the header only when it is repeated?

Thanks much!
Re: How to change style of Repeated Header [message #1001400 is a reply to message #1001393] Wed, 16 January 2013 11:33 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

How are you running the report? Are you using the Viewer or the API? If you are using the API are you using separate run and render tasks? Look at the attached example that shows one way of doing this. I did the example in BIRT 2.6.

Jason
Re: How to change style of Repeated Header [message #1001423 is a reply to message #1001400] Wed, 16 January 2013 12:05 Go to previous messageGo to next message
Ann Black-Ziegelbein is currently offline Ann Black-Ziegelbein
Messages: 5
Registered: June 2012
Junior Member
Thanks so much for the example and speedy response, Jason! This is an interesting example, and I was trying to do similar scripting stuff. However, I really need to change the header itself, the way I have my layout done, I can not easily add in a detail row to place "continued" into. I augmented your sample slightly to move the "continued" into the header and it does not appear - it looks like the header line only gets evaluated initially and then not again for all repeats of the header. Is there a way to change the repeated header elements - or only add something to the detail rows?

I am programmatically generating the report using a run & render task such as:

IReportRunnable design = engine.openReportDesign(reportName);
IRunAndRenderTask task = engine.createRunAndRenderTask(design);
task.setParameterValue(parmName, parmValue);

// Create the PDF Render Option object here ...
IPDFRenderOption pdfOptions = new PDFRenderOption();
pdfOptions.setOutputFormat(PDFRenderOption.OUTPUT_FORMAT_PDF);
pdfOptions.setOutputFileName(outputFileName);


task.setRenderOption(pdfOptions);

task.run();
task.close();

I can send you our report if you would like to take a look, but would prefer to send it directly vs. posting to the forum due to the nature of the report.

Thanks again!!!
Re: How to change style of Repeated Header [message #1001937 is a reply to message #1001423] Thu, 17 January 2013 10:31 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Can you try using separate run and render tasks? Something like the following:

IReportRunnable design = null;
design = engine.openReportDesign("Reports/TopNPercent.rptdesign");
IRunTask task = engine.createRunTask(design);
task.setLocale(new Locale("en", "US"));
task.run("output/resample/TopNPercent.rptdocument");
task.close();

document = engine.openReportDocument("output/resample/TopNPercent.rptdocument");


PDFRenderOption options = new PDFRenderOption();
options.setOption(IRenderOption.HTML_PAGINATION, Boolean.TRUE );
options.setOutputFileName("output/resample/topnpercent.pdf");
options.setOutputFormat("pdf");




IRenderTask rtask = engine.createRenderTask(document);
rtask.setLocale(new Locale("en", "US"));
rtask.setRenderOption(options);
rtask.render();
rtask.close();
document.close();
Jason
Re: How to change style of Repeated Header [message #1004164 is a reply to message #1001937] Tue, 22 January 2013 12:59 Go to previous messageGo to next message
Ann Black-Ziegelbein is currently offline Ann Black-Ziegelbein
Messages: 5
Registered: June 2012
Junior Member
Thanks Jason,

I gave this a try with the sample report you provided, only I moved the "Continued" into the header row (rather than detail). I still do not see the events being invoked for the repeated header rows?

Should it have worked and I need to double check my logic for errors?
Re: How to change style of Repeated Header [message #1004299 is a reply to message #1004164] Tue, 22 January 2013 18:54 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Did you not see the onRender event fire?
Add something like this to the onRender event for the group header?
importPackage( Packages.java.io );
out = new PrintWriter( new FileWriter( "c:/temp/pgevents.txt", true ) );
out.println( "group header onRender "+ pageNumber);
out.close();

Jason
Re: How to change style of Repeated Header [message #1004702 is a reply to message #1004299] Wed, 23 January 2013 12:40 Go to previous messageGo to next message
Ann Black-Ziegelbein is currently offline Ann Black-Ziegelbein
Messages: 5
Registered: June 2012
Junior Member
Thanks Jason!

I see them now. I think part of what was causing me problems is that in the final render task, there are no page break events that get emitted (page break events are only in the run task). I added in some additional logic to the onRender, however, that would preserve the id of the last rendered header and when the lastID == idToRenderNow then I could change the background styles. I think this should do what I need it to, I am going to work on integrating the sample into my main report today.

Just so I can be more knowledgable going forward - is there a document page somewhere that talks about the events that get emitted during run vs. render when separating the tasks?

Thanks again for all your help - greatly appreciate it!

Re: How to change style of Repeated Header [message #1005495 is a reply to message #1004702] Fri, 25 January 2013 12:06 Go to previous message
Jason Weathersby is currently offline Jason Weathersby
Messages: 9167
Registered: July 2009
Senior Member

Ann

Look at the following links:
http://www.eclipse.org/birt/phoenix/deploy/reportScripting.php
Chart scripting:
http://birtworld.blogspot.com/2010/08/birt-charting-scripting-overview.html
crosstab scripting
http://birtworld.blogspot.com/2010/02/birt-crosstab-scripting.html
Page Scripts:
http://www.eclipse.org/birt/phoenix/project/notable2.5.php#jump_4

We also document the process pretty well in 4 chapters of the integrating and extending book.

Jason
Previous Topic:How to fixe a header row in a CrossTab?
Next Topic:What properties are passed to an IScriptFunctionExecutor in IScriptFunctionContext?
Goto Forum:
  


Current Time: Thu Jul 24 23:41:30 EDT 2014

Powered by FUDForum. Page generated in 0.01860 seconds