function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
SubhamSubham 

how to convert Column value in to link.

Hey Guys,

 

There are two requirement corresponding to this.

 

1> Lets Say  there is a country column. displaying values from a custom object. now if the value is US.then in that case  us should be a link but other value in that column should be output text .

here is my code snippet

 

<apex:column rendered="{!somecondition}" >


                        <apex:facet name="header"><apex:outputText style="font-weight:bold; font-weight:900; font-size:120%"       value="Country"></apex:outputText></apex:facet>
                        <apex:outputLink style="color:blue;" >
                            {!FA.Country}&nbsp;
</apex:outputLink>
</apex:column>

 

in this case all the values become a command link ,  but i want it to be done only when country = US

 

2> Now another requirement is to open a overlay (Pop-up) on click of it without getting the page refresh. and pass the value of country name . in my case its US.

 

Regards,

 

 

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

You'd need to specify two versions of the column body and render the appropriate one depending on the value, something like:

 

<apex:outputLink style="color:blue;" rendered="{!FA.Country=='US'}">
     {!FA.Country}&nbsp;
</apex:outputLink>
<apex:outputText style="color:blue;" rendered="{!FA.Country!='US'}">
     {!FA.Country}&nbsp;
</apex:outputText>

 To create a popup, you can simply give the link a target of _blank.  Assuming the popup page is '/apex/Country', you'd do the following:

 

<apex:outputLink style="color:blue;" value="/apex/Country?county={!FA.Country}" rendered="{!FA.Country=='US'}">
     {!FA.Country}&nbsp;
</apex:outputLink>

 although the browser may choose to display this in a new tab rather than a popup.

 

All Answers

kiranmutturukiranmutturu

try this

 

<apex:column>

<apex:outputlink rendered="{!FA.Country=='US'}" value="{!string}"/>

<apex:outputfield rendered="NOT({!FA.Country=='US'})" value="{!FA.Country}"/>

</apex:column>

bob_buzzardbob_buzzard

You'd need to specify two versions of the column body and render the appropriate one depending on the value, something like:

 

<apex:outputLink style="color:blue;" rendered="{!FA.Country=='US'}">
     {!FA.Country}&nbsp;
</apex:outputLink>
<apex:outputText style="color:blue;" rendered="{!FA.Country!='US'}">
     {!FA.Country}&nbsp;
</apex:outputText>

 To create a popup, you can simply give the link a target of _blank.  Assuming the popup page is '/apex/Country', you'd do the following:

 

<apex:outputLink style="color:blue;" value="/apex/Country?county={!FA.Country}" rendered="{!FA.Country=='US'}">
     {!FA.Country}&nbsp;
</apex:outputLink>

 although the browser may choose to display this in a new tab rather than a popup.

 

This was selected as the best answer
SubhamSubham

Thanks guys for your reply.

 

 

Actually i m using 'United states of america ' instead of US

 

The column becomes kind of Big.

 

how can i wrap text .

 

Regards,

 

 

kiranmutturukiranmutturu

use facet and put the value as  United<br/>states<br/>of<br/>america

bob_buzzardbob_buzzard

You can set the size of the column through inline styling.  When the text would be too large, the browser will break on whitespace.  

bprakashbprakash
 {!FA.Country}&nbsp;

in this wht is &nbsp

Pls explain me how it works

bob_buzzardbob_buzzard

Its a non-breaking space.  It allows you to embed whitespace into a web page.

bprakashbprakash

Thx Bob