How to make items (columns) in <apex:pageBlockTable> hyperlink?

33,840

Instead of <apex:column value="{!item.name}" />, try doing it like this in the column body:

<apex:pageBlock title="test">
        <apex:pageBlockTable value="{!workObj}" var="item">
         <apex:column>
              <apex:outputLink value="{!item.name}">{!item.name}</apex:outputLink>
         </apex:column>
    <apex:pageBlock title="test">
<apex:pageBlockTable value="{!workObj}" var="item">
Share:
33,840
Meow
Author by

Meow

I'm a cat.

Updated on June 15, 2020

Comments

  • Meow
    Meow about 4 years

    I successfully created tables with style that salesforce provided. (like the one that highlighted on mouseover etc)

    But I want the value of column to be a link to display detail info of the object. When I don't create my own visualforce page, the table looks nice and the column values (records) are all hyperlinked but can't figure out how to do it from visualforce apex code.

    pageBlockTable and column definition does not seem to have attributes or anything that make it hyperlink.

    http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_pageBlockTable.htm
    http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_column.htm

    <apex:pageBlock title="test">
        <apex:pageBlockTable value="{!workObj}" var="item">
            <!-- below needs to be hyperlink -->
            <apex:column value="{!item.name}" /> 
        </apex:pageBlockTable>
    </apex:pageBlock>
    

    I could achieve my goal by throwing the good design away like below but I would like to keep the code above.

    This works but no salesforce style is applied.

     <apex:pageBlock title="my test title" >    
                <apex:dataTable value="{!workObj}" var="wn" cellpadding="2" cellspacing="2">
                    <apex:column>
                        <apex:facet name="header">仕事名一覧</apex:facet>
                        <apex:form >
                            <apex:commandLink value="{!wn.name}" />
                        </apex:form>
                    </apex:column>
                </apex:dataTable>
        </apex:pageBlock>