1

I am trying to creating some table headers for my table in my visualforce page, but when loaded on the internet only the table body is shown.

Apex:

<apex:page showHeader="false" title="My Orders" standardController="Service_Order__c" recordSetVar="orders">
  <apex:composition template="{!$Site.Template}">
    <apex:define name="body">  

    <h2>My Orders</h2>
    <p>Orders will go here</p>

    <apex:dataTable value="{!orders}" var="so" width="100%">

        <table>
            <thead>
                <tr>
                    <th>ID</th>
                    <th>Name</th>
                    <th></th>
                </tr>
            </thead>
            <tbody>
                <tr>
                    <td>
                        <apex:column >
                            <apex:outputText value="{!so.Id}"/>
                        </apex:column>
                    </td>
                    <td>
                        <apex:column >
                            <apex:outputText value="{!so.Name}"/>
                        </apex:column>
                    </td>
                    <td>
                        <apex:column >
                            <apex:outputLink styleClass="" value="/{!so.id}">VIEW</apex:outputLink>
                        </apex:column>
                    </td>
                </tr>
            </tbody>
        </table>

    </apex:dataTable> 

    </apex:define>
  </apex:composition>
</apex:page>
0
3

Theres a few things wrong, such as the apex:column should be a child of apex:dataTable

If you are trying to create your table in HTML then you can try using a apex:repeat tag to repeat over each of the orders.

<table>
    <thead>
        <tr>
            <th>ID</th>
            <th>Name</th>
            <th></th>
        </tr>
    </thead>
    <tbody>
        <apex:repeat var="so" value="{!orders}">
            <tr>
                <td>
                    <apex:outputText value="{!so.Id}"/>
                </td>
                <td>
                     <apex:outputText value="{!so.Name}"/>
                </td>
                <td>
                    <apex:outputLink styleClass="" value="/{!so.id}">VIEW</apex:outputLink>
                </td>
            </tr>
         </apex:repeat>
    </tbody>
</table>

but if you really want to use apex:dataTable then the example below should work:

<apex:dataTable value="{!orders}" var="so">
    <apex:column>
        <apex:facet name="header">Id</apex:facet>
        <apex:outputText value="{!so.Id}"/>
    </apex:column>
    <apex:column>
        <apex:facet name="header">Name</apex:facet>
        <apex:outputText value="{!so.Name}"/>
    </apex:column>
    <apex:column>
        <apex:facet name="header"></apex:facet>
        <apex:outputLink styleClass="" value="/{!so.id}">VIEW</apex:outputLink>
    </apex:column>
</apex:dataTable>
2

Why don't you use the example given in the doc :

   <apex:dataTable value="{!orders}" var="so" width="100%">
       <apex:column >
           <apex:facet name="header">ID</apex:facet>
           <apex:outputText value="{!so.Id}"/>
       </apex:column>

       <apex:column >
           <apex:facet name="header">Name</apex:facet>
           <apex:outputText value="{!so.Name}"/>
       </apex:column>

       <apex:column >
           <apex:outputLink styleClass="" value="/{!so.id}">VIEW</apex:outputLink>
       </apex:column>
</apex:dataTable>

See : http://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_dataTable.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.