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)
Variable page number
sabu22
<p>Hi ,</p><p> </p><p>I requirre to use page number as a variable. Can this be achieved using Birt 4.2.0?. Can i use this variable for putting visibility conditions in my report?</p><p> </p><p>The <view-time value>pageNumber</view-time value> always returns 1 .</p><p> </p><p>Any help is appreciated</p><p>Thanks</p>
Find more posts tagged with
Comments
kclark
<p>Where are you placing pageNumber? If you place it in onRender() it's only executed once so you'll only have 1 of 1 pages. You'd need to use pageNumber in the onCreate() of the item so you get the correct number of pages/correct currentPage. What are you trying to control the visibility of? I think you should be able to select that item > visibility. Then use an expression like this</p><pre class="_prettyXprint _lang-">if(pageNumber == 1) { false; // invisible}else if(pageNumber == 2) { false;} //continued</pre>
sabu22
<p>I am trying to place this visibility on a text. The above solution is not working .</p><p>Actually my requirrement is like new headers for different pages. So I am trying to add a condition like :</p><p><strong class='bbc'>if</strong> (pageNumber==1){</p><p><strong class='bbc'>false</strong>;</p><p>}</p><p><strong class='bbc'>else</strong> <strong class='bbc'>if</strong> (pageNumber==2){</p><p><strong class='bbc'>true</strong>;</p><p>}</p><p> </p><p>but it is not working</p><p> </p><p>So i am adding all the texts in grid in masterpage and providing corresponding visibility conditions.</p><p> </p><p>My report does not have any tables through which i can group on the basis of one particular row.</p><p>I basically have lots of static text and images in my report and also i have not forced any page breaks in my report. All the page breaks are automatic.</p><p>So in such condition i have to put headers on my report</p>
kclark
<p>I'm sorry I meant to say place the code in the onCreate() not onRender(), why are you using a grid for static headers on different pages? You could use a script like this.</p><pre class="_prettyXprint">if(pageNumber == 1) { this.text = "Static header 1"}else if(pageNumber ==2) { this.text = "Static header 2"}else if(pageNumber == 3) { this.text = "Static header 3"}</pre><p>So you don't need to have more than one label.</p>
sabu22
<p>Hi Clark,</p><p> </p><p>I tried the method given above , but i found out that this was only working if i manually added some page breaks to it. In my report I am getting the page breaks automatically. The page number is only incrementing when i am manually forcing some page breaks in my report.</p><p>I have put a list and i am adding all the static data to it. I think maybe if i could set some global variable or a PGV while page break. with some text. then i might be able to change the header.</p><p> </p><p>I tried it by setting a PGV on the onPageBreak script and then some how if i could use that PGV in add it to my label like</p><p>this.text=reportContext.getPersistentGlobalVariable('header');</p><p>Then i might be able to change the header but it didnt work.</p><p>I am not able to access the PGV on the onCreate script of the label.</p><p> </p><p>I am just attaching a dummy rptdesign. It does not have any datasource just some static texts. It is a very basic report so please dont mind.</p><p> </p><p> </p><p>Thanks for your help</p><p>