Jump to content

BIRT Developer Center
Download


Photo
- - - - -

Truncate URL text but keep the hyperlink


  • Please log in to reply
2 replies to this topic

#1 cvh

cvh

    Member

  • Members
  • PipPip
  • 17 posts

Posted 29 March 2012 - 03:40 AM

[previously posted in the Designing BIRT reports forum but reposting here as no responses there]

Hello all. I'm very much a BIRT novice.

I'm using the following code in the 'onRender' section of the script page to set the hyperlink in a column of my report:

var myaction = this.createAction();
myaction.setHyperlink(this.getValue(),"_blank");
this.action = myaction;

This works nicely.

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.

Can anyone give me a pointer how to do it, please?

#2 JasonW

JasonW

    Senior Member

  • Members
  • 2505 posts

Posted 30 March 2012 - 08:45 AM

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

#3 cvh

cvh

    Member

  • Members
  • PipPip
  • 17 posts

Posted 02 April 2012 - 01:42 AM

Thanks very much Jason, that works just fine.

For anyone else reading this - I combined Jason's code with mine as follows:

var url = this.getValue();
this.setDisplayValue(url.substring(0,20));

var myaction = this.createAction();
myaction.setHyperlink(url,"_blank");
this.action = myaction;