Jump to content
  • 0

Conditional display of link in a table


SteveMott

Question

Hi

I am trying to introduce a link into a table column based on the presence or absence of a value in a field. Ideally if the field is null the link (SMQ) in the pic is not displayed (or a message is displayed as in the code below).

image.png.b520ce385cfa5688c6dcebc09f4c02a5.png

I am not sure if the best solution is a case-when-then or a javascript.

Here's the statement in code format (it doesn't work - just displays the <a href... in the table!):

CASE
WHEN [@field:SMQcode] <> ''
THEN '<a href = "https://website.html?
SMQcode=[@field:SMQcode]&ATClevel2ID=[@field:primaryATClevel2ID]&Level2=Yes">SMQ</a>'
ELSE 'No SMQ available'
END

 

Any advice would be greatly appreciated.

Thanks

Steve

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0

Hi @SteveMott,

your case when can actually work (with a few changes), but since you are trying to output an <a> tag which is an HTML element, it wouldnt render on calc field alone, so you would have to pass in the result of the calc field to an HTML block. 

 

First, your Formula on the Calc Field would have to be:

CASE
WHEN [@field:SMQcode] = ''
THEN 'No SMQ available'
ELSE '<a href = "https://website.html?
SMQcode=[@field:SMQcode]&ATClevel2ID=[@field:primaryATClevel2ID]&Level2=Yes">SMQ</a>'
END

 

For the HTML block calling in the value of the Calculated Field:

image.png.05eaaac77ec4a5746ec73cbdbf9308ee.png

 

Then, you'd simply have to hide the Calculated Field column using CSS:

 

<style>

table tr th:nth-child(3), table tr td:nth-child(3){
display: none;
}

</style>

 

wherein 3 refers to the third column in my Tabular Report because that's the order where the Calculated Field comes in. Just change it to whatever order your Calc Field comes in.

 

Hope this helps!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...