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
WilksyWilksy 

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.

Best Answer chosen by Admin (Salesforce Developers) 
SPDSPD

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

SPDSPD
try using facet inside panel grid for each column...
WilksyWilksy
Thanks for the suggestion.  Using the header facet simply puts a single row at the top with a single piece of text.  I need a heading for each column, rather than a heading for the table itself.
SPDSPD

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

WilksyWilksy

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:smileysurprised: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? 

SPDSPD

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">

This was selected as the best answer
WilksyWilksy

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>

 

 

 

SPDSPD
great... :smileyhappy: