Home
Analytics
Expression for padding
huis
hi there:
I have a specific question on padding....
I want to know if it's possible to add expression on some textbox padding...
like if condition = true then top padding = 10pt...
It can be done easily in MS Reporting Service... but when I tried to convert to
BIRT report, I don't know where to put the expression...
thanks
Hui
Find more posts tagged with
Comments
mwilliams
Hi Hui,
You can set the padding in the onCreate script with the following code:
this.getStyle().paddingRight = "10 points"
".".paddingLeft = "10 points"
".".paddingTop = "10 points"
".".paddingBottom = "10 points"
Hope this helps.
huis
Thanks mike... I am pretty new to BIRT and where could I find the OnCreate script? is that a built-in script or I have to create on my own?<br />
I am a Reporting service report designer and am having a painful time switching to BIRT...<br />
<br />
thanks<br />
<br />
Hui<br />
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>Hi Hui,<br />
<br />
You can set the padding in the onCreate script with the following code:<br />
<br />
this.getStyle().paddingRight = "10 points"<br />
".".paddingLeft = "10 points"<br />
".".paddingTop = "10 points"<br />
".".paddingBottom = "10 points"<br />
<br />
Hope this helps.</p></blockquote>
mwilliams
Hui,
Sorry, if you click on the element you want to add the conditional padding to, then click on the "script" tab below the design window, you'll see a drop down where you can select onCreate. This will be the onCreate script method for that element. You can do a conditional statement here to add/remove padding. Let me know if you have any other questions.
huis
thanks... if I'd like to put more conditions into the onCreate script...for example,<br />
if a field is_folder = 't', then this.getStyle().paddingRight = "10 points"<br />
how can i do that? also, is there any document for the script syntax?<br />
<br />
thanks<br />
<br />
Hui<br />
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>Hui,<br />
<br />
Sorry, if you click on the element you want to add the conditional padding to, then click on the "script" tab below the design window, you'll see a drop down where you can select onCreate. This will be the onCreate script method for that element. You can do a conditional statement here to add/remove padding. Let me know if you have any other questions.</p></blockquote>
mwilliams
Hui,<br />
<br />
You should be able to put something like:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if ( row["is_folder"] == "t"){
this.getStyle().paddingRight = "10 points";
}
else{
this.getStyle().paddingRight = "1 points";
}
</pre>
<br />
The syntax for the script methods is just standard java/javascript which you can find information on by searching google, etc. The API documentation should help you out some with functions and what not:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/modules/documentation/#currentdocs'>All
Products - Documentation - BIRT Exchange</a><br />
<br />
Let me know if you have any more questions.
huis
Perfect! thanks a lot, mike....<br />
<br />
Hui<br />
<br />
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>Hui,<br />
<br />
You should be able to put something like:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>
if ( row["is_folder"] == "t"){
this.getStyle().paddingRight = "10 points";
}
else{
this.getStyle().paddingRight = "1 points";
}
</pre>
<br />
The syntax for the script methods is just standard java/javascript which you can find information on by searching google, etc. The API documentation should help you out some with functions and what not:<br />
<br />
<a class='bbc_url' href='
http://www.birt-exchange.org/modules/documentation/#currentdocs'>All
Products - Documentation - BIRT Exchange</a><br />
<br />
Let me know if you have any more questions.</p></blockquote>
mwilliams
No problem. Let us know whenever you have questions.
hag
Hi,
Thanks for this helpful tip. I used the expression 'if (row["SUBITEM_FROM"]>0) {this.getStyle().paddingLeft = "40 points"};'
It works well, but only with IE, and not with Firefox, Opera or Chrome or Safari (runtime 2.6.1).
The expression is also ignored when I export the report to pdf. Do you have any suggestion?
Thanks a lot.
mwilliams
If you set the padding in the property editor of the designer rather than in script, does it work in those other browsers?
hag
Yes, in all the browsers and also in the pdf export. Only the paddings defined in the scripts are ignored.
mwilliams
Which script method are you putting this into? Have you tried moving it to any of the others? Also, you might try downloading 2.6.2 and seeing if it has the same issue.
pricher
Hui,
The code snippet sent earlier by Michael was wrong. To change the padding via script, the syntax should be:
this.getStyle().paddingLeft = "20pt";
not
this.getStyle().paddingLeft = "20 points";
This works fine with IE and Firefox.
P.
mwilliams
My mistake.
hag
Thanks a lot! Now it works, also for the PDF export.
best, hag