Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
dynamic Table header on pagebreak
hatra
<p>Hi All,</p>
<p>I have one other issue regarding page break.</p>
<p>I have a table that has one header ( Scenario) and 11 detail rows( number of the rows always stay the same) I want to apply a logic to the header so if it goes to next page it shows " Scenario ( continued ). Actuate BIRT designer professional 11.0.4</p>
<p> </p>
Find more posts tagged with
Comments
Matthew L.
<p>Using some logic created to display the current page number and number of pages in a group "n of m", I dropped in this code and changed the display line for the header labels onRender call.</p>
<p> </p>
<p>See the attached example.</p>
<p> </p>
<p>Code applied to the table's footer row onCreate method:</p>
<pre class="_prettyXprint _lang-js">
//
//
// This code group calculates the total number of pages in a Table Group and sets vars based on page number each page in that group
//
// To use: Place this entire code block into a Table's Group FooterRow.
// Call the following global values to retreve their values.
// For Current Page In Group: reportContext.getPersistentGlobalVariable("PageCounter" + pageNumber.toString());
// For Total Pages In Group : reportContext.getPersistentGlobalVariable("GroupCounter" + pageNumber.toString());
//
// Example:
// Place the following example into a Dynamic Text element's onRender Method in the Master Page to display "Page n of m" where m is the total pages per group.
//
// CurrentPage = reportContext.getPersistentGlobalVariable("PageCounter" + pageNumber.toString()); //Set CurrentPage var from global var "PageCounter"
// GroupTotal = reportContext.getPersistentGlobalVariable("GroupCounter" + pageNumber.toString()); //Set GroupTotal var from global var "GroupCounter"
// this.text = "Page " + CurrentPage + " of " + GroupTotal; //Set output text to: Page # of #
//
//
lastGroupPageNum = parseInt(reportContext.getPersistentGlobalVariable("PageHolder")); //Set lastGroupPageNum var from global var "PageHolder"
if (!lastGroupPageNum) {lastGroupPageNum = 0;} //If this is first run then set lastGroupPageNum to 0
pagesInGroup = pageNumber - lastGroupPageNum; //Subtract lastGroupPageNum from Current page to get pagesInGroup
pageDiffCount = pagesInGroup; //Copy pagesInGroup to pageDiffCount
while (pageDiffCount-- > 0) { //Loop through all pages in a group
inBetweenPages = lastGroupPageNum + pageDiffCount + 1; //Calculate the inBetweenPages page numbers of the pages between groups
reportContext.setPersistentGlobalVariable("GroupCounter" + inBetweenPages.toString(),pagesInGroup.toString()); //Set the GroupCounter for each page
reportContext.setPersistentGlobalVariable("PageCounter" + inBetweenPages.toString(),(pageDiffCount+1).toString()); //Set the PageCounter for each page
} //End pageDiffCount loop
reportContext.setPersistentGlobalVariable("PageHolder",pageNumber.toString()); //Set global var "PageHolder" as reference for last group page
//
</pre>
<p>Code applied to the header label's onRender method:</p>
<pre class="_prettyXprint _lang-js">
//
//
// This code group displays "Page n of m" on each page where m is the total number of pages in a Table group.
//
// This code requires the logic code found in a Table's Group FooterRow onCreate method to work
//
CurrentPage = reportContext.getPersistentGlobalVariable("PageCounter" + pageNumber.toString()); //Set CurrentPage var from global var "PageCounter"
GroupTotal = reportContext.getPersistentGlobalVariable("GroupCounter" + pageNumber.toString()); //Set GroupTotal var from global var "GroupCounter"
//this.text = "Page " + CurrentPage + " of " + GroupTotal; //Set output text to: Page # of #
if(CurrentPage != GroupTotal)
this.text += " (Continued...)";
//
</pre>
hatra
<p>Hi Matthew,</p>
<p>thanks for your respond and this logic works partially great, however I am trying to modify it to the report I have but I have a challenge to get it working, the table I am trying to get the header changed depend on whether it breaks to next page or not may be on first, second or third page of report and I only wanted to show scenario (Continued) if scenario table goes to next page. any suggestions please?</p>
Matthew L.
<p>Perhaps I'm not understanding what the issue is.</p>
<p>Could you clarify what you are trying to accomplish?</p>
<p>Or do you have screenshots you can share or an example report I could review to better understand what you are wanting to accomplish?</p>
hatra
<p>unfortunately I can't post or attach anything becasue if tight security.</p>
<p>I have a table at the end of my report, this report has 5+ tables, report output could be 2 or 3 pages, I want to apply a logic to this table ( Scenario ) so if this table breaks to next page ( could be 2nd or 3rd page) header repeats and show " Scenario Countinued"</p>
<p> </p>
<p>first page</p>
<p>
</p>
<p>table one</p>
<p>xxxxxxxxx</p>
<p> </p>
<p>table two</p>
<p> </p>
<p>zzzzzzzzs</p>
<p> </p>
<p>Scenario ( final table )</p>
<p>vvvvvvvvvvvvvvv</p>
<p> </p>
<p>Page two</p>
<p>
</p>
<p> </p>
<p>Scenario Continued</p>
<p> </p>
<p>ddddddddddddddddddddddddd</p>
<p> </p>
<p> </p>
<p> </p>
<p>I hope this is a little clearer</p>
<p> </p>
<p>thanks</p>
Matthew L.
<p>I see what you are trying to accomplish now.</p>
<p>Change "GroupTotal" to '1' on line 10 of the Label's onRender method to produce the results your looking for</p>
<pre class="_prettyXprint _lang-js _linenums:1">
//
//
// This code group displays "Page n of m" on each page where m is the total number of pages in a Table group.
//
// This code requires the logic code found in a Table's Group FooterRow onCreate method to work
//
CurrentPage = reportContext.getPersistentGlobalVariable("PageCounter" + pageNumber.toString()); //Set CurrentPage var from global var "PageCounter"
//GroupTotal = reportContext.getPersistentGlobalVariable("GroupCounter" + pageNumber.toString()); //Set GroupTotal var from global var "GroupCounter"
//this.text = "Page " + CurrentPage + " of " + GroupTotal; //Set output text to: Page # of #
if(CurrentPage != 1)
this.text += " (Continued...)";
//
</pre>
hatra
<p>Thanks Matthew,</p>
<p>It worked on the sample report you sent me, and I created a few table and forced it to break to next page and it works beautifuly, how ever on my report it ignores it, Not sure what stopping it, need to check it a little more.
</p>
hatra
<p>unfortunately It isnt working in my report.</p>
<p>Any other technique or logic?</p>
Matthew L.
<p>Its strange that it works in the example but not in your own design.</p>
<p>Could you post your report design to examine?</p>
hatra
<p>I agree Matthew this is strange, Unfortunately because of tight security I cant attach or apply screenshot here.</p>
<p>But to test I applied the code on other report header and footer and didnt work there either.</p>
<p>In the footer code there are a few area which talk about "Groups"</p>
<p>in the sample and neither my report I have group header or footer, does it need to have?</p>
Matthew L.
<p>Actually no, the original code was written to display the page number of groups.</p>
<p>The logic is designed to count the total number of pages in a group (or Table in our case here), and provide the current page number per that group (or Table).</p>
<p>In our case here, we are using this logic to update the header label to show "(Continued...)" instead of "Page n of m".</p>
<p> </p>
<p>Make sure in your report that the main code is in the table's footer row (onCreate method).</p>
<p>And the display code is on the header label's OnRender method.</p>
<p> </p>
<p>Also, are you deploying to Maximo?</p>
<p>I've received word that this code might not work in a Maximo environment.</p>
hatra
<p>I have placed them on header and footer as per your instrocture, I will be deploying it on iserver ( iHub). however I havent got it working on BIRT report designer yet.</p>
<p>could this not work to write logic on table OnpageBreak level something like:</p>
<p> </p>
<p>if table xxxx true and if pagebreak inside true</p>
<p>table header + continued?</p>
Matthew L.
<p>My original attempt was to use the pagebreak methods, however after a quick test I noticed that you cannot set the Label's text in the pagebreak method.</p>
<p>Which version/build of BIRT are you using?</p>
hatra
<p>Actuate BIRT Designer Professional Version 11.0.4. (3.2.23)</p>
Matthew L.
<p>My apologies I should have been more clear.</p>
<p>Could you send me the build number of the designer you are using (Help -> About).</p>
<p>Also if your About box doesn't look similar to mine (Shows Actuate logo on left), please attach it so that I can verify that the designer is properly loading the professional tools.</p>
<p> </p>
<p>With this information, I can verify that something in the particular build of this designer does not cause the issue with the code.</p>
hatra
<p>No problem,</p>
<p>Build id: 20121023</p>
<p>I have also applied</p>
<p> </p>
<p>reportContext.setPersistentGlobalVariable ( "v_Continued",test1");
on report initialize</p>
<p>this.text +=reportContext.getPersistentGlobalVariable(v_Continued");
on table lable cell onRender</p>
<p>and</p>
<p>reportContext.setPersistantGlobalVarible ("v_Continued", "(Continuedtest)");
on table onPageBreak</p>
<p> </p>
<p>and on the report i get scenariodaniel on both pages of the report ,</p>
<p>you think this could work?</p>
<p>cheers</p>
Matthew L.
<p>That doesn't work for me, are you able to get code like that to work in your environment?</p>
<p> </p>
<p>Also, you indicated that you were able to run my previous example in your environment and it worked for you.</p>
<p>However attempting to implement the same solution in your design, does not work.</p>
<p>Unfortunately unless you can post a sample report to examine, I cannot determine why my example works for you but does not work in your own report.</p>
<p>My suggestion is to look over the example carefully and determine if it was implemented in the same way in your report design.</p>
hatra
<p>Thanks Matthew,</p>
<p>I will keep trying to find a way.</p>
<p>Cheers</p>
hatra
<p>hi,</p>
<p>I found out that the report doesnt recon page number.</p>
<p>I have page numbe on master page 1 of 1, 1 of 2 etc but when I view the report it shows 1 /2 on first page and the same on second page , how ever on top right cornor it say go to page 2. could this be the issue? and any idea how to fix it? is it a bug?</p>
hatra
<p>one more update,</p>
<p>I fixed the page number ( it is mor eof a bug i believe on Desktop Viewer prototype ), now the logic work when I run the report on Actuate iserver viewer but when I export it to pdf it wont show ???</p>
Matthew L.
<p>Using the attached (unmodified) report in BIRT Designer Professional 11SP4 Fix1 and running directly to PDF as well as running to the Interactive Viewer (IV) then Exporting the Content as PDF.</p>
<p>The code seems to work (See attached PDF).</p>
<p> </p>
<p>However when using the Open Source 2.6.2 designer, running directly to PDF does not work.</p>
<p>When running in the Open Source 4.4.1 designer, the code runs but places the (Continued...) on every table header.</p>
<p> </p>
<p>My theory is that this due to how the Open Source designer uses "RunAndRender" in a single step, while the Professional designers use "RunThenRender" as 2 separate steps.</p>
<p> </p>
<p>Please test the attached design in your Actuate BIRT Designer Professional 11SP4 Fix1 designer to see that the PDF output should match the output PDF I've attached here.</p>
hatra
<p>Hi Matthew,</p>
<p>Your sample works perfectly,</p>
<p>I have modified my report and it works when when you directly run on on viewer and when run it on PDF or even export the content into PDF it wont work.</p>