Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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>
like image 935
Meow Avatar asked Dec 04 '22 10:12

Meow


1 Answers

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">
like image 114
ryanbrainard Avatar answered Mar 05 '23 20:03

ryanbrainard