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
timainmantimainman 

Visualforce: dataList + <table> tag producing bad HTML...bug??

I have a standard HTML table tag that has three columns in each column I am trying to render a apex:dataList by passing a list of data to it.

 

Here is my code:

 

 

 

<tr>
<td><strong>Capabilities 1:</strong>
<apex:dataList value="{!sk.sh1}" var="skh">
<apex:outputText value="{!skh.Characteristic__c}"/>
</apex:dataList>
</td>
<td><strong>Capabilities 2:</strong>
<apex:dataList value="{!sk.sh2}" var="skh">
<apex:outputText value="{!skh.Characteristic__c}"/>
</apex:dataList>
</td><td><strong>Capabilities 3:</strong>
<apex:dataList value="{!sk.sh3}" var="skh">
<apex:outputText value="{!skh.Characteristic__c}"/>
</apex:dataList>
</td>
</tr>

 

When the page renders it renders the table like this:

 

 

 

<tr>
<td><strong>Capabilities 1:</strong></td>
</tr>
<tr>
<td class="data2Col first " colSpan="2">
<ul class="" id="j_id0:j_id2:db:0:j_id3:j_id13:j_id15">
<li id="j_id0:j_id2:db:0:j_id3:j_id13:j_id15:0" class="">A/B ratio 1/8 or worse</li>
<li id="j_id0:j_id2:db:0:j_id3:j_id13:j_id15:1" class="">&#8220;Power Promoter&#8221; letters reflect no attemp</li>
</ul>
</td>
</tr>
<tr>
<td class="data2Col first " colSpan="2"></td>
<td><strong>Capabilities 2 :</strong></td>
</tr>
<tr>
<td class="data2Col first " colSpan="2">
<ul class="" id="j_id0:j_id2:db:0:j_id3:j_id13:j_id18">
<li id="j_id0:j_id2:db:0:j_id3:j_id13:j_id18:0" class="">&#8220;Power Promoter&#8221; letters reflect inconsistent attempt to create Action Plan</li>
</ul>
</td>
</tr>
<tr>
<td class="data2Col first " colSpan="2"></td>
<td><strong>Capabilities 3:</strong></td>
</tr>
<tr>
<td class="data2Col first " colSpan="2">
<ul class="" id="j_id0:j_id2:db:0:j_id3:j_id13:j_id21">
<li id="j_id0:j_id2:db:0:j_id3:j_id13:j_id21:0" class="">&#8220;Power Promoter&#8221; letters reflect consistent ability to create Action Plan</li></ul>
</td>
</tr>
<tr>
<td class="data2Col first last " colSpan="2"> </td>
</tr>

 

As you can see it is sticking in a bunch of extra <tr> & <td> tags. I even tried to render the List with apex:repeat and apx:datatable and still got the issue.

 

Any thoughts/ideas would be appreciated. Thanks!

 

 
ConejoConejo

I have the same issue.

 

I have 2 nested <apex:repeat>'s inside an <apex:pageBlockSection>, and I'm getting an extra <tr> rendered.

 

The extra tag is: <tr><td class="data2Col  first " colspan="2"></td></tr>

 

I'll post a minimal test case tomorrow night when I have more time. If anyone has any ideas before then or would let me know that this is a known issue, I sure would appreciate it. 

 

Thanks,

 

Rich C. 

AdriansmalleyAdriansmalley

Arg i am getting the same problem. Ironically using a nested query works fine eg. below... Maybe this is a work around? Did anyone find a solution to this problem? the RefProd loop is bad but the rest is fine. :smileymad:

 

 

<apex:page standardController="Territory_Product_Budget__c" extensions="AcctProdModel">
<apex:form >
<apex:pageBlock mode="Edit">
<apex:pageBlockButtons >
<apex:commandButton action="{!save}" value="Save"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<table border="1" col="16">
<tr><td>Account Plan</td><td>MS in Use</td><td>SKU M/S</td><td>Fix</td>
<apex:repeat value="{!refProd}" var="TerrProd" first="0" rows="12">
<td><apex:outputText value="{!TerrProd.Cascaded_Target__c}" escape="false"/></td>
</apex:repeat>
</tr>
<apex:repeat value="{!Prods}" var="AcctProd">
<tr><td>Account Plan</td><td>MS in Use</td><td>SKU M/S</td><td>Fix</td>
<apex:repeat value="{!AcctProd.Account_Product_Monthly_Forecasts__r}" var="head1" first="0" rows="12">
<td><apex:outputText escape="false" value="{!head1.Month_formula__c}" style="width:25px"/></td>
</apex:repeat>
</tr>
<tr>
<td><apex:outputText value="{!AcctProd.SFDC_Acct_Plan__r.name}"/></td>
<td><apex:outputText value="{!AcctProd.M_S_in_use__c}"/></td>
<td><apex:inputText value="{!AcctProd.M_S_uplift__c}" style="width:25px"/></td>
<td><apex:inputField value="{!AcctProd.Accept_Target__c}"/></td>
<apex:repeat value="{!AcctProd.Account_Product_Monthly_Forecasts__r}" var="Test1">
<td width="50px">
<apex:inputField value="{!Test1.Accepted_Target__c}" style="width:30px"/>
</td>
</apex:repeat>
</tr>
</apex:repeat>
</table>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

 

 

SFmaverickSFmaverick

It's my belief that the problem are you having is using a data list and a table together. A Data List outputs 1 piece of data per row, for multiple rows. An HTML Table is built one row at a time, from left to right, top to bottom. So when you try to put a data list into the html table, it's going to create a new <tr> and <td> tag for each piece of data it puts out.

 

I'm not 100% sure on that, but it makes since according to how i've experienced their functionality. I'd suggest greating a seperate 1 column table for each data list and then just putting them side by side.