Home
Analytics
Change Table margin dynamically based on Page number
shivkumar150
<p>Hi,</p>
<p> </p>
<p>I want to change the top margin of a table dynamically based on the pageNumber. If it is the first page, the <strong>table.marginTop</strong> should be <strong>0pt</strong> (just under a preceding grid), else on a new page, it should be 10pt.</p>
<p>I have found the method, but just don't know what is the type of pageNumber, so that I can compare it with integer(1,2.3). I have placed the following script in <em>onPrepare()</em> function, but it is picking value from <strong>else</strong> bracket</p>
<div>
<pre class="_prettyXprint">
if(pageNumber == 1){
this.getStyle().marginTop="0pt";
}
else{
this.getStyle().marginTop="10pt";
}</pre>
<p>When I try <em>pageNumber.compareTo(1)</em>, I get an error, "<b><span>Cannot find function compareTo in object 0". </span></b></p>
<p><span>I suspect pageNumber gets value after the page rendering.</span></p>
</div>
<p> </p>
Find more posts tagged with
Comments
pricher
<p>Hi,</p>
<p> </p>
<p>The onPrepare event is called once for each report element in the design. As you have noticed, pageNumber will always be 0 if you evaluate it in onPrepare.</p>
<p> </p>
<p>I am trying to understand your requirements. But if all you want is display a grid on the first page above the table, then on subsequent pages, move down the table to leave the amount of space taken by the grid, you can do this by adding a blank header row to your table, make it the same height as your grid, and hide it through scripting when on the first page in the onRender event of that blank header row. The script reads like this:</p>
<pre class="_prettyXprint _lang-js">
if (pageNumber == 1)
this.height = "0pt"
</pre>
<p>I have attached a working sample.</p>
<p> </p>
<p>Hope this helps,</p>
<p> </p>
<p>P.</p>
<p> </p>
<p>PS: Follow this <a data-ipb='nomediaparse' href='
http://www.eclipse.org/birt/documentation/integrating/scripting.php'>link
</a>for a thorough explanation of events and the order they are fired.</p>
<p> </p>