Jump to content

Setting a calculated value as hyperlink in text area


Rudy Ratner

Recommended Posts

Hi,

I have a calculated column asa hyperlink in my table, that is constructed using various column elements for each row.

The column property is as a Link Template {$} so when a user clicks on a value in the column it opens up the url in a webpage.

I have a text area that places the value of the calculated column based on Marking (when the user selects the row, the hyperlink shows up in the text area so that the user doesn't have to scroll to the column to openit)

However, it is just showing up as a string and not a hyperlink in the text area.

Is there any way to make it a clickable hyperlink in the text area

Thank You

Link to comment
Share on other sites

Hi there,

To do this I think you would need to use a small amount of javascript. I use a method to do this type of thing often in my Spotfire tools. Here is how to achieve this:

 

In your text area edit the HTML

Create an empty hyperlink/anchor tag and give it an id (we will refer to this id in the Javascript).

Add a div tag and give it an id

Inside this div tag, create a calculated value control and make the value of this calculated value equal to your hyperlink column and set it to react to marking. For instance use unique concatenate on the value.

Your HTML of your text area should look something like this: (Note I have added a style to hide the div content so the user doesn't not see it:

 

Hyperlink:

 

 

 

 

Now add a JS script to the text area and add this code:

$(function() {

 

 

// bind to watch for changes to the marked row

$('#marked-row').bind('DOMSubtreeModified',function(){

 

// get the value of the calculated value

var link = $('#marked-row').text().trim();

 

// now update the link

// set the text

$('#selected-row-hyperlink').text(link)

// set the actual link to visit

$('#selected-row-hyperlink').attr("href", link)

 

});

});Now when the marking changes, the link should update. You may want to handle when no marking is done by wrapping the calculated value expression in the SN function which allows you to set the value to a blank string when the calculated value is null for instance:

SN(UniqueConcatenate(),"")You can read more similar tricks like this here:

https://community.spotfire.com/wiki/using-spotfire-text-areas-increase-usability-analytics-through-html-javascript-and-css

Hope this helps

Thanks

Colin

Link to comment
Share on other sites

Thank you so much for that info!

 

I tried it and it does show up as a link in the text area. However, when I click on it, instead of opening it in my web browser, it just greys out my entire Spotfire client (dcube). Almost as if it is trying to open the link in the client.

 

Have you run into this issue too

Link to comment
Share on other sites

Thank you, that works in opening my web browser, however, I get localhost page not found and has two http: protocols as shown in the screenshot v.phpi=8745c416a0here.

 

Looks like it is routing through a local server.  The link in my calculated column has only one https protocol.

 

Is there any way to discard the preceding http:

Link to comment
Share on other sites

I think there may be some form of proxy at play on your server/network. When I try this in a web player, it just opens the web page link as is. I would use Chrome (or browser) developer tools to ensure the href is correct first when viewing the link in the web player. If it is, then possibly there is something else intercepting the link.

Thanks

Colin

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...