BIRT Exchange Forum: Truncate URL text but keep the hyperlink - BIRT Exchange Forum

Jump to content


 

BIRT Poll: To best make a table fill a pdf page before breaking (PL=page layout, PBI=page break interval) set:

PL: auto, PBI: 0PL: fixed, PBI: 0PL: auto, PBI: 1000000PL: fixed, PBI: 1000000
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Truncate URL text but keep the hyperlink Rate Topic: -----

#1 User is offline   cvh Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 17
  • Joined: 26-October 10


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?
0

#2 User is offline   JasonW Icon

  • Senior Member
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 2505
  • Joined: 08-August 07


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
0

#3 User is offline   cvh Icon

  • Member
  • PipPip
  • Group: Members
  • Posts: 17
  • Joined: 26-October 10


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;

0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users