You need to sign in to do that
Don't have an account?

Column headings for apex:outputPanel
Hi
I'm creating a VisualForce email template and am using apex:outputPanel to produce a list.
How do I get a single row at the top of the table with column headings?
<apex:repeat var="line" value="{!relatedTo.OpportunityLineItems}">
<apex:outputPanel rendered="{!line.priceBookEntry.product2.family = 'Licence, support & update cover'}" >
<apex:panelGrid columns="3" columnClasses="left,left,right" width="100%">
<apex:outputField value="{!line.priceBookEntry.product2.name}"/>
<apex:outputField value="{!line.priceBookEntry.product2.description}"/>
<apex:outputField value="{!line.TotalPrice}"/>
</apex:panelGrid>
</apex:outputPanel>
</apex:repeat>
This gives me the list I want, but can't work out how to head up each column.
i think you can use outputfield inside <td>..
<td><apex:outputfield value = "{!line.TotalPrice}"/></td> ....
if that doesnt work..try giving fixed width to td..
for eg:
<td width = "100">
All Answers
try this...
<apex:outputpanel>
<tr>
<td width="">Col 1</td>
<td width="">Col 2</td>
<td width="">Col 3</td>
</tr>
<tr>
<td width="">Your Column values </td>
<td width="">Your Column values</td>
<td width="">Your Column values</td>
</tr>
</apex:outputpanel>
Note that i am not using panelGrid inside outputPanel
Thanks for suggesting reverting to html. I started with that but was having problems formatting <td>{!line.TotalPrice}</td> as a monetary value. I thought that by using <apex
utputField value="{!line.TotalPrice}"/> I would be able to show it as £x,xxx.xx. When I use <td> instead of <apex OutputField> I get the value showing as 7000.0 (missing last decimal place and no , ) rather than £7,000.00.
Any suggestions on how I can resolve the formatting?
i think you can use outputfield inside <td>..
<td><apex:outputfield value = "{!line.TotalPrice}"/></td> ....
if that doesnt work..try giving fixed width to td..
for eg:
<td width = "100">
Brilliant! Yes, you can use an apex output field within a <td>. The bit of code now looks like below.
Note I've also been able to use the rendered attribute to restrict the records returned in the repeat section to a single family of products.
<table border="1"; width="100%"; > <tr> <th align="left"; valign="top"; width="40%"; >Product</th> <th align="left"; valign="top"; width="40%"; >Comments</th> <th align="right"; valign="top"; width="20%"; >Amount £ exc VAT</th> </tr> <apex:repeat var="prods" value="{!relatedTo.OpportunityLineItems}"> <apex:outputPanel rendered="{!prods.priceBookEntry.product2.family = 'Licence, support & update cover'}" > <td align="left"; valign="top"; width="40%"; >{!prods.priceBookEntry.product2.name}</td> <td align="left"; valign="top"; width="40%"; >{!prods.Description}</td> <td align="right"; valign="top"; width="20%"; ><apex:outputfield value="{!prods.TotalPrice}"/></td> </apex:outputPanel> </apex:repeat> </table>