Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » Changing style of hyperlinks
Changing style of hyperlinks [message #693585] Wed, 06 July 2011 19:46 Go to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
I have some labels for which I have defined as hyperlinks. When they are rendered in the viewer they are shown with an underline. I was wondering if it would be possible to also have the color change from the browser standard "link not taken" and "link taken" colors.
Re: Changing style of hyperlinks [message #693683 is a reply to message #693585] Thu, 07 July 2011 01:50 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

Take a look at these:
http://www.birt-exchange.org/org/devshare/designing-birt-reports/1311-removing-underline-from-hyperlink/
or
http://www.birt-exchange.org/org/forum/index.php/topic/9266-formatting-a-web-hyperlink/

Jason


On 7/6/2011 3:46 PM, Mike Wulkan wrote:
> I have some labels for which I have defined as hyperlinks. When they are
> rendered in the viewer they are shown with an underline. I was wondering
> if it would be possible to also have the color change from the browser
> standard "link not taken" and "link taken" colors.
Re: Changing style of hyperlinks [message #693889 is a reply to message #693683] Thu, 07 July 2011 13:03 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
I tried the onRender technique as described in one of the links you kindly provided.
I put in:
this.getStyle().textTransform = "UPPERCASE";
just to see if it was working and this worked fine but as far as underlines go I tried

this.getStyle().textUnderline = "FALSE";
this.getStyle().textUnderline = "";
this.getStyle().textUnderline = "false";
this.getStyle().textUnderline = false;

and none of them seemed to have any effect.

Re: Changing style of hyperlinks [message #694483 is a reply to message #693889] Fri, 08 July 2011 17:27 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike

Did you try the text element approach?
<a href="http://www.google.com"
style="text-decoration:none;color:green;font-size:9pt"
onmouseover="this.style.color = 'tan'"
onmouseout="this.style.color = 'green'">
<VALUE-OF>row["ORDERNUMBER"]</VALUE-OF></a>

Jason

On 7/7/2011 9:03 AM, Mike Wulkan wrote:
> I tried the onRender technique as described in one of the links you
> kindly provided.
> I put in:
> this.getStyle().textTransform = "UPPERCASE";
> just to see if it was working and this worked fine but as far as
> underlines go I tried
>
> this.getStyle().textUnderline = "FALSE";
> this.getStyle().textUnderline = "";
> this.getStyle().textUnderline = "false";
> this.getStyle().textUnderline = false;
>
> and none of them seemed to have any effect.
>
>
Re: Changing style of hyperlinks [message #694485 is a reply to message #693889] Fri, 08 July 2011 17:27 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike

Did you try the text element approach?
<a href="http://www.google.com"
style="text-decoration:none;color:green;font-size:9pt"
onmouseover="this.style.color = 'tan'"
onmouseout="this.style.color = 'green'">
<VALUE-OF>row["ORDERNUMBER"]</VALUE-OF></a>

Jason

On 7/7/2011 9:03 AM, Mike Wulkan wrote:
> I tried the onRender technique as described in one of the links you
> kindly provided.
> I put in:
> this.getStyle().textTransform = "UPPERCASE";
> just to see if it was working and this worked fine but as far as
> underlines go I tried
>
> this.getStyle().textUnderline = "FALSE";
> this.getStyle().textUnderline = "";
> this.getStyle().textUnderline = "false";
> this.getStyle().textUnderline = false;
>
> and none of them seemed to have any effect.
>
>
Re: Changing style of hyperlinks [message #694531 is a reply to message #694483] Fri, 08 July 2011 19:16 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
I didn't because the link is a drill down to another report and I didn't know how to easily construct the URL for it and get the same behavior that I generate from the GUI.
Re: Changing style of hyperlinks [message #694567 is a reply to message #694531] Fri, 08 July 2011 21:02 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike,

Try adding a text element with some script like:


<script type="text/javascript">
function doAll(){
var anchors = document.getElementsByTagName('A');
for (ii=0;ii<anchors.length;ii++) {
anchors[ii].style.textDecoration="none";
}

}

doAll();
</script>

Jason

On 7/8/2011 3:16 PM, Mike Wulkan wrote:
> I didn't because the link is a drill down to another report and I didn't
> know how to easily construct the URL for it and get the same behavior
> that I generate from the GUI.
Re: Changing style of hyperlinks [message #817112 is a reply to message #694567] Fri, 09 March 2012 16:48 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Jason,
I added the code as described and it works great. Now the only issue that I have is that I'd like to limit the anchors to which the doAll function processes. Currently this function changes the style of all the links on the page. Is there a way of giving an id to certain links and then conditioning the body of the loop to check for some sort of naming convention to decide how to set the style?
I'm using the GUI to generate the drill-through hyperlinks so I'm just not sure if and where you can set an id attribute on the link and how one could reference it in the script?

Thanks,
Mike
Re: Changing style of hyperlinks [message #817273 is a reply to message #817112] Fri, 09 March 2012 21:50 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike

Change your doAll function to something like:

function doAll(){

var anchors = document.getElementsByTagName('A');
for (ii=0;ii<anchors.length;ii++) {

if( anchors[ii].parentNode.id ){
if (anchors[ii].parentNode.id.indexOf("myhyperlink") !=-1) {
anchors[ii].style.textDecoration="none";
}
}

}

}

Then in the data elements that you want to change set a bookmark
expression to something like:
"myhyperlink"+row.__rownum

Jason

On 3/9/2012 11:48 AM, Mike Wulkan wrote:
> Hi Jason,
> I added the code as described and it works great. Now the only issue
> that I have is that I'd like to limit the anchors to which the doAll
> function processes. Currently this function changes the style of all the
> links on the page. Is there a way of giving an id to certain links and
> then conditioning the body of the loop to check for some sort of naming
> convention to decide how to set the style?
> I'm using the GUI to generate the drill-through hyperlinks so I'm just
> not sure if and where you can set an id attribute on the link and how
> one could reference it in the script?
>
> Thanks,
> Mike
Re: Changing style of hyperlinks [message #819101 is a reply to message #817273] Mon, 12 March 2012 13:48 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Thanks Jason, works like a charm Very Happy

If I could trouble you for one more tweak.

What I am attempting to do is create a header with links to the other pages in my report. The code you have provided takes care of removing the underlines from these links. I have the header specified as a grid element in my rptlibrary and have included it at the top of each of my reports. What I would like is that the link associated with the currently displayed report be formatted specially to indicate that it is the current page.

I was thinking I could do that by comparing the bookmark that I have now added to the link element as per your current suggestion (I named each explicitly rather than using rownum) , with the title of the report. I could do this as a highlight condition for the link element.

The one part of this I am not sure how to achieve is retrieving the page title attribute in this context?
Re: Changing style of hyperlinks [message #819193 is a reply to message #819101] Mon, 12 March 2012 15:56 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Mike

Do you mean the general report property title?
If so you should be able to access it in server side script or in an
expression like:
reportContext.getDesignHandle().getProperty("title");

Jason

On 3/12/2012 9:48 AM, Mike Wulkan wrote:
> Thanks Jason, works like a charm :d
> If I could trouble you for one more tweak.
>
> What I am attempting to do is create a header with links to the other
> pages in my report. The code you have provided takes care of removing
> the underlines from these links. I have the header specified as a grid
> element in my rptlibrary and have included it at the top of each of my
> reports. What I would like is that the link associated with the
> currently displayed report be formatted specially to indicate that it is
> the current page.
> I was thinking I could do that by comparing the bookmark that I have now
> added to the link element as per your current suggestion (I named each
> explicitly rather than using rownum) , with the title of the report. I
> could do this as a highlight condition for the link element.
>
> The one part of this I am not sure how to achieve is retrieving the page
> title attribute in this context?
Re: Changing style of hyperlinks [message #819216 is a reply to message #819193] Mon, 12 March 2012 16:30 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Yup, that is exactly what I wanted.

Finally (I hope), is there a way to make a dynamic reference to the text of a label element within a highlight script?

I currently have:
reportContext.getDesignHandle().getProperty("title").indexOf("Home") == 0

but I'd like to replace the string "Home" with a reference to the text of the label element so that I could use the same script for all my TOC links without having to hard-code the same text string in the script.
Re: Changing style of hyperlinks [message #819220 is a reply to message #819216] Mon, 12 March 2012 16:35 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Okay I lied... one more thing,

In the highlight dialog, I see a drop-down for Apply Style. Currently it is set to None but the list is empty. On my regular report pages I see that I can create a named Style but this element is in a rptlibrary and for some reason there is not Style definition section. So how do I define a common style that I can use in my highlight definition so that I don't have to code it separately for each link?
Re: Changing style of hyperlinks [message #819393 is a reply to message #819216] Mon, 12 March 2012 21:44 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

What do you mean dynamic? If its a label within the report and it is
named you can gets its design time value using:
reportContext.getDesignHandle().findElement("mylabel").getText();

Jason

On 3/12/2012 12:31 PM, Mike Wulkan wrote:
> Yup, that is exactly what I wanted.
>
> Finally (I hope), is there a way to make a dynamic reference to the text
> of a label element within a highlight script?
> I currently have:
> reportContext.getDesignHandle().getProperty("title").indexOf("Home") == 0
>
> but I'd like to replace the string "Home" with a reference to the text
> of the label element so that I could use the same script for all my TOC
> links without having to hard-code the same text string in the script.
Re: Changing style of hyperlinks [message #819397 is a reply to message #819220] Mon, 12 March 2012 21:45 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If you open up the library you should be able to add styles there.

Jason

On 3/12/2012 12:35 PM, Mike Wulkan wrote:
> Okay I lied... one more thing,
>
> In the highlight dialog, I see a drop-down for Apply Style. Currently it
> is set to None but the list is empty. On my regular report pages I see
> that I can create a named Style but this element is in a rptlibrary and
> for some reason there is not Style definition section. So how do I
> define a common style that I can use in my highlight definition so that
> I don't have to code it separately for each link?
Re: Changing style of hyperlinks [message #819872 is a reply to message #819393] Tue, 13 March 2012 12:33 Go to previous messageGo to next message
Mike Wulkan is currently offline Mike WulkanFriend
Messages: 147
Registered: July 2009
Senior Member
Having to name the label element and find it by name just shifts the issue. What I was hoping for was that I could use the relative location of where the script is running to find the label so that I wouldn't have to know it's name.
Eg., I have a grid and in each cell I have a label. I would like the highlight of the cell to be based on the a script that references the text of the label in the cell. I'd like the script to be generic in that it could be used for each cell. Having to name the label and reference that name in the script defeats this purpose.

Jason, I appreciate your time on this, however you may feel free to regard this particular question as low priority as I have already implemented this in the non-generic way but am still curious to learn if there is a better technique to use in the future.

With regards to the styles in the library. I may just be being thick, but I don't see any place to add styles in the library.

In the outline view of the library I see:
...
MasterPages
Themes
Embedded Images
Libraries
Scripts

However in the outline view of a rptdesign is see:
MasterPages
Styles
Embedded Images
Libraries
Scripts

Why is the Styles node not available in outline view of the library? Is this not the place where I would add a style? In the rptdesign file I can right click this node and select New Style... but there is no place I can see to do that in the library?
Re: Changing style of hyperlinks [message #820085 is a reply to message #819872] Tue, 13 March 2012 17:52 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

I do not know of an easy way of doing this.
Styles in Libraries
Expand themes and right click on default and you will see you can add a
style.

Jason

On 3/13/2012 8:33 AM, Mike Wulkan wrote:
> Having to name the label element and find it by name just shifts the
> issue. What I was hoping for was that I could use the relative location
> of where the script is running to find the label so that I wouldn't have
> to know it's name.
> Eg., I have a grid and in each cell I have a label. I would like the
> highlight of the cell to be based on the a script that references the
> text of the label in the cell. I'd like the script to be generic in that
> it could be used for each cell. Having to name the label and reference
> that name in the script defeats this purpose.
>
> Jason, I appreciate your time on this, however you may feel free to
> regard this particular question as low priority as I have already
> implemented this in the non-generic way but am still curious to learn if
> there is a better technique to use in the future.
>
> With regards to the styles in the library. I may just be being thick,
> but I don't see any place to add styles in the library.
> In the outline view of the library I see:
> ...
> MasterPages
> Themes
> Embedded Images
> Libraries
> Scripts
>
> However in the outline view of a rptdesign is see:
> MasterPages
> Styles
> Embedded Images
> Libraries
> Scripts
>
> Why is the Styles node not available in outline view of the library? Is
> this not the place where I would add a style? In the rptdesign file I
> can right click this node and select New Style... but there is no place
> I can see to do that in the library?
Re: Changing style of hyperlinks [message #947108 is a reply to message #820085] Tue, 16 October 2012 20:36 Go to previous messageGo to next message
Deborah Rogina is currently offline Deborah RoginaFriend
Messages: 3
Registered: October 2012
Junior Member
I have a similar problem and have implemented the javascript solution above, but it only seems to work in Internet Explorer. I have not had any success in Firefox or Chrome. I believe there is a bug between Birt 3.7.1 and Chrome in which Chrome does not read in line HTML/javascript. But I don't know why it wouldn't work in Firefox.

Any suggestions?

I'm using:
Birt 3.7.1
Firefox 15.0.1
Internet Explorer 9
Chrome 22.0.1229.94 m

Debbie
Re: Changing style of hyperlinks [message #947402 is a reply to message #947108] Wed, 17 October 2012 03:51 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Which method did you use?

Jason
Re: Changing style of hyperlinks [message #948862 is a reply to message #947402] Thu, 18 October 2012 13:00 Go to previous messageGo to next message
Deborah Rogina is currently offline Deborah RoginaFriend
Messages: 3
Registered: October 2012
Junior Member
I'm using this block of code in a text item on the report:

<script type="text/javascript">
function doAll(){

	var anchors = document.getElementsByTagName('A');
	for (ii=0;ii<anchors.length;ii++) {

		if( anchors[ii].parentNode.id ){
			var id = anchors[ii].parentNode.id;
		
			if (anchors[ii].parentNode.id.indexOf(id) !=-1) {
				anchors[ii].style.textDecoration="none";
			}	
		}	

	}

}

doAll();
</script>


Re: Changing style of hyperlinks [message #949377 is a reply to message #948862] Fri, 19 October 2012 00:00 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Any chance you could try BIRT 3.7.2? It worked for me.

Jason
Re: Changing style of hyperlinks [message #953968 is a reply to message #947402] Mon, 22 October 2012 17:34 Go to previous message
Deborah Rogina is currently offline Deborah RoginaFriend
Messages: 3
Registered: October 2012
Junior Member
No I'm on 3.7.1 and it's not an option to upgrade at this time.

[Updated on: Mon, 22 October 2012 17:34]

Report message to a moderator

Previous Topic:Can't show dynamic image from sqlite
Next Topic:Hide row if element is empty
Goto Forum:
  


Current Time: Tue Apr 16 23:39:36 GMT 2024

Powered by FUDForum. Page generated in 3.31309 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top