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)
Truncate URL text but keep the hyperlink
cvh
[previously posted in the Designing BIRT reports forum but reposting here as no responses there]<br />
<br />
Hello all. I'm very much a BIRT novice.<br />
<br />
I'm using the following code in the 'onRender' section of the script page to set the hyperlink in a column of my report:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var myaction = this.createAction();
myaction.setHyperlink(this.getValue(),"_blank");
this.action = myaction;</pre>
<br />
This works nicely. <br />
<br />
However, I'd like to truncate the text representation of the URL when its exceeds a given character count, and yet retain the hyperlink itself.<br />
<br />
Can anyone give me a pointer how to do it, please?
Find more posts tagged with
Comments
JasonW
I assume this is on a data item? If so you can set the display value like:
var myurldisp = this.getValue();
this.setDisplayValue(myurldisp.substring(0,20));
Jason
cvh
Thanks very much Jason, that works just fine.<br />
<br />
For anyone else reading this - I combined Jason's code with mine as follows:<br />
<br />
<pre class='_prettyXprint _lang-auto _linenums:0'>var url = this.getValue();
this.setDisplayValue(url.substring(0,20));
var myaction = this.createAction();
myaction.setHyperlink(url,"_blank");
this.action = myaction;</pre>