salesforce - VisualForce 中的嵌套表问题

标签 salesforce apex-code visualforce

我在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>

最佳答案

我不能说这是否真的是一个错误,但我相信它是由 <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>

关于salesforce - VisualForce 中的嵌套表问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10806950/

相关文章:

excel - 在 VF 页面中导出 Excel - 使用动态图像 URL 时图像未显示

jquery - 获取错误 : Uncaught TypeError: undefined is not a function bootstrap. js :29 (anonymous function) bootstrap. js:29(匿名函数)

java - 使用 Salesforce WSC API 的 setAccount 给出未索引的字段

machine-learning - kNN 中的特征选择和重要特征

java - 如何从 HttpResponse java 获取信息?

salesforce - Salesforce My 域应首先在哪里创建?沙盒或生产

javascript检查这种格式的字符串

eclipse-plugin - Apex 编辑器支持代码格式

apex-code - 你能用 soql 填充一个集合吗?

javascript - Uncaught ReferenceError : <mapkey> is not defined