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)
set PageBreakInterval dynamically during onCreate
pratikgala
<p>I have two tables on a page: </p>
<p> </p>
<p>the size/number of rows in the two tables are variable. </p>
<p> </p>
<p>The problem I am facing is, that when both the tables have rows more than the page can fit, but less than the pagebreakInterval of the two tables which is set to 34,40 respectively, the tables shrink and wrap.</p>
<p> </p>
<p>hence I am trying to write this code to stop the wrapping on the onCreate function of table 2.</p>
<p> </p>
<p>//table 1</p>
<div>var t1 = reportContext.getPersistentGlobalVariable("totRowCountTbl1");</div>
<div> </div>
<div>//table 2</div>
<div>var t2 = this.getRowData().getExpressionValue("row[Aggregation_1]");</div>
<div> </div>
<div>var val; </div>
<div> </div>
<div>if(t1 != 0){</div>
<div> val = t1 % 34; //34 is the max number of rows that can fit in the page. </div>
<div> // val stores the remainder of rows left on the new page to be displayed.</div>
<div> // I use this info to determine where to break the table 2. </div>
<div>}</div>
<div> </div>
<div> </div>
<div>if(t1 != 0){</div>
<div> if(t2 != 0){</div>
<div> var sum = parseInt(t1) + parseInt(t2);</div>
<div> </div>
<div> if(val == 0 ){</div>
<div> this.getStyle().pageBreakBefore = "Always";</div>
<div> }</div>
<div> if(val != 0 ){</div>
<div> var t2Break = Math.abs(val - 34);</div>
<div> log("t2"+t2Break);</div>
<div> </div>
<div>// the code below does not take any effect (whats wrong here)</div>
<div> </div>
<div>reportContext.getDesignHandle().findElement("table2Name").setIntProperty("pageBreakInterval",t2Break);</div>
<div> }<span> </span></div>
<div> }</div>
<div>}</div>
<div> </div>
<div>also BUG: the pageBreakInside does not have any effect when set to auto, hence all this code above. </div>
<div> </div>
<div>Thanks for the help in advanced. </div>
<div> </div>
<div> </div>
<div> </div>
Find more posts tagged with
Comments
JFreeman
<p>Are you getting any errors with your code?</p>
<p> </p>
<p>One thing that jumps out at me is your are doing a setIntProperty() for the PageBreakInterval but I want to say this should be set through SetProperty() instead.</p>
pratikgala
<blockquote class="ipsBlockquote" data-author="JFreeman" data-cid="137190" data-time="1434557209">
<div>
<p>Are you getting any errors with your code?</p>
<p> </p>
<p>One thing that jumps out at me is your are doing a setIntProperty() for the PageBreakInterval but I want to say this should be set through SetProperty() instead.</p>
</div>
</blockquote>
<p> </p>
<p>the code is not giving any errors but it does not break the table at the interval specified. The table breaks at its originally set pageBreakInterval property. </p>
<p> </p>
<p>I have tried SetProperty and its the same as before. no errors and the table does not break at the specified interval. <br><br>
The reason I need this dynamic property is because, </p>
<p> </p>
<p>supposing table 1 takes 130% of the page</p>
<p> the table 1 will take 100% of the page (break the table at its page interval number) and the remaining 30% of the next page</p>
<p>now the table 2 supposing has a size of 100% </p>
<p> it will take the 100% from the 70% of the 2nd page ( which causes the page to shrink wrap.)making the actual page size of 130%. <br><br>
Hence the code is calculating the actual rows that can fit from table 2 and will set a page break interval at the position where the number of rows can fit.. <br><br>
But I also need to reinitialize the page break Interval to the original interval number. <br><br>
This case only occurs when there are two defined in the same page. <br>
And their sizes are variable.<br>
</p>
<p> </p>
<p> </p>
<p>
</p>
JFreeman
<p>I'm not sure i'm clear on your description of exactly what is happening when you refer to how the tables "shrink and wrap".</p>
<p> </p>
<p>Is it possible for you to create and attach a sample report using classic models or a flat file data source that replicates the issue?</p>
pratikgala
<blockquote class="ipsBlockquote" data-author="JFreeman" data-cid="137207" data-time="1434569128">
<div>
<p>I'm not sure i'm clear on your description of exactly what is happening when you refer to how the tables "shrink and wrap".</p>
<p> </p>
<p>Is it possible for you to create and attach a sample report using classic models or a flat file data source that replicates the issue?</p>
</div>
</blockquote>
<p>Give me some time, I created a sample, </p>
<p>I was trying to create the same issue, but it actually solved my problem atleast in the sample its working the way I want. <br>
So if I can solve it in my original report then its solved. <br>
For now lets put this on hold.<br><br>
will get back tomorrow. <br>
thanks for the help<br>
much appreciated</p>
JFreeman
<p>Sounds good.</p>
<p>I will keep an eye out for another update.</p>