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
alexcfalexcf 

Adding more text to an apex:outputField (and apex:repeat adding <td> tags)

Hi,

 

I've been struggling this evening with apex:repeat and also trying to get extra text into this:

 

<apex:outputField style="font-weight:bold;right" title="Total: " value="{!Quote__c.Quote_Amount__c}"/>

 

If I made that an outputText then I lose the currency which is a pain... And, as apex:repeat adds:

<apex:panelGrid columns="2" width="100%">
<tr><td>Header 1</td><td>Header2</td></tr>
<apex:repeat><td> (this is the auto created one)
<tr><td><apex:outputField value="bla"/></td><td>Something else here</td></tr>
</td>(and it closes here)</apex:repeat>
</apex:panelGrid>

all on it's own, it completely  screws up any tables if you're trying to use <tr>. i.e. tables with a repeat would come out like above.

 

Is there something I'm doing wrong..? :)

 

Thanks in advance for any help and suggestions, it's been bugging me for hours!

 

~acf

 

 

Message Edited by alexcf on 11-01-2009 04:14 PM
SFDCDev7SFDCDev7

Hi Alex,

 

Check the below link. Hope it helps.

 

http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=6247

 

-AJ

alexcfalexcf

Hi AJ,

 

Worked a treat, thanks very much..!

 

You don't happen to have the answer regarding the apex:repeat <td>'s do you? :)

 

~acf.

SFDCDev7SFDCDev7

Can you explain more about the issue which you face for 'repeat' tag ?

 

-AJ

alexcfalexcf

Sure, this is the code:

 

 

<apex:repeat value="{!SFDC_520_Quote__c.quote_lines__r}" var="line"> <tr><td><apex:outputText value="{!line.product2__r.productcode}"/></td> <td><apex:outputField value="{!line.Qty_Ordered__c}"/></td> <td><apex:outputField value="{!line.product2__r.description}"/></td> <td><apex:outputField value="{!line.Unit_Net_Price__c}"/></td> <td align="right"><apex:outputField value="{!line.Ext_Net_Price__c}"/></td> </tr> </apex:repeat>

 

 The output is:

 

 

<td> <tr><td>shipping</td> <td><span id="j_id0:j_id67:1:j_id71">1,234</span></td> <td><span id="j_id0:j_id67:1:j_id73"></span></td> <td><span id="j_id0:j_id67:1:j_id75">£2.00</span></td> <td align="right"><span id="j_id0:j_id67:1:j_id77">£2,468.00</span></td> </tr> </td>

 

The <td> and </td> create problems for the table layouts as it's entering another column unnecessarily.

 

 

~acf

 

 

bob_buzzardbob_buzzard
I think you are getting bonus <td> characters because of the panelGrid. Each component inside a panelGrid is added as a table cell (so inside <td> tags).  Your repeat is a component, and thus has <td> appear before the repeated content and </td> after the repeated content.
alexcfalexcf

Hmm, OK. Can you think of a way around this, as I'm trying to create a table of outputted information? I've sorted a work around by entering random <td>'s all over my code, which is *far* from pretty nor am I happy with it! :)

 

After what you've said, it completely makes sense now, it's just a real pain. :)

 

Thanks,

 

~acf

 

SFDCDev7SFDCDev7

Hi

 

Instead of repeat use dataTable. check the below sample code.

 

<apex:dataTable value="{!SFDC_520_Quote__c.quote_lines__r}" var="Line">
  <apex:column width="13%" > <center> {!Line.Name}</center></apex:column>
  <apex:column width="17%" > <center> {!Line.Description__c}</center></apex:column>
</apex:dataTable> 

 

Hope it helps.

 

-AJ

bob_buzzardbob_buzzard

I assume you've investigated using a pageBlockTable?  If you have and found it wanting, I would suggest that you don't use the panelGrid and just handle things using repeat tags.  E.g.

<table> <tr> <td>Heading1</td> <td>Heading2</td> </tr> <apex:repeat value="{!myList}" var=element> <tr> <td><apex:outputField value="{!element.field1}"/></td> <td><apex:outputField value="{!element.field2}"/></td> </tr> </apex:repeat> </table>

 

 

 

alexcfalexcf

Hi guys,

 

Thanks for the information. The label bit sorted me out! I'll give the data bits a go at a later date.

 

Thanks again!

 

~acf.