我在force.com apex模板上的pageBlockSection中有一个表。这工作正常,直到我尝试在我的一个单元格中使用outputText标记。当我使用此标记时,额外的单元格和行将添加到标记中。但是,如果我没有将我的表嵌套在pageBlockSection标记内,则不会添加这样的单元格。
我是否错误地使用了outputText,或者在force.com上是否有错误?
以下是重现此问题的最小标记:
<apex:pageBlock title="My Page Block">
<apex:pageBlockSection title="My Section">
<table>
<tr><th>1</th><th>2</th></tr>
<tr>
<td>
<apex:outputText value="{0}">
<apex:param value="one" />
</apex:outputText>
</td>
<td>
<apex:outputText value="{0}">
<apex:param value="two" />
</apex:outputText>
</td>
</tr>
</table>
</apex:pageBlockSection>
</apex:pageBlock>
这是force.com提供的输出:
<table>
<tbody>
<tr><th>1</th><th>2</th></tr>
<tr>
<td></td>
<td colspan="2" class="dataCol first ">one</td>
</tr>
<tr>
<td colspan="2" class="dataCol "></td>
<td></td>
<td colspan="2" class="dataCol ">two</td>
</tr>
<tr>
<td colspan="2" class="dataCol last "></td>
</tr>
</tbody>
</table>
答案 0 :(得分:4)
它是否实际上是一个我不能说的错误,但我相信它是由<apex:pageBlockSection>
引起的,因为它们会自动将嵌套内容添加到表中,然后会与您自己的表发生冲突。
我建议您删除<apex:pageBlockSection>
并将表格直接放入<apex:pageBlock>
,或删除自己的表格并改为使用<apex:pageBlockSectionItem>
元素:
<apex:pageBlock title="My Page Block">
<apex:pageBlockSection title="My Section">
<apex:pageBlockSectionItem >
1
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
2
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="{0}">
<apex:param value="one" />
</apex:outputText>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem >
<apex:outputText value="{0}">
<apex:param value="two" />
</apex:outputText>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
答案 1 :(得分:1)
通过将表放在outputPanel标记中,我能够解决这个问题。
<apex:pageBlockSection>
<apex:outputPanel>
<table>
</table>
</apex:outputPanel>
</apex:pageBlockSection>