2

I have a pageBlockTable similar to the structure below. Is it possible to add another header row to the table? I attempted duplicating the existing header lines but that did not work. As a workaround, is it possible to add a new line to the text of the existing header row?

<apex:pageblockTable value="{!temp}" var="temp" id="temp_table">
<apex:column >
    <apex:facet name="header">
        <apex:outputText value="Header1"></apex:outputText>
    </apex:facet>
    <apex:outputText value="1"/>
</apex:column>
    <apex:column >
    <apex:facet name="header">
        <apex:outputText value="Header1"></apex:outputText>
    </apex:facet>
    <apex:outputText value="2"/>
</apex:column>
<apex:column >
    <apex:facet name="header">
        <apex:outputText value="Header1"></apex:outputText>
    </apex:facet>
        <apex:outputText value="3"/>
    </apex:column>

6
  • How did you try that? Duplicating the whole facet or just the outputText? It seems like the latter should work.
    – Adrian Larson
    Nov 25, 2015 at 16:36
  • I tried both and neither worked. Nov 25, 2015 at 16:40
  • you can use html table and use pageblockTable css for displaying like pageblockTable
    – Ratan Paul
    Nov 25, 2015 at 17:03
  • did you try adding a facet name="header" as a descendent of pageBlockTable?
    – cropredy
    Nov 25, 2015 at 17:44
  • @crop1645 I tried this and it works but it spans the entire table. Ideally I would have a column in the header for each column in the body of the table. Nov 25, 2015 at 18:43

2 Answers 2

1

Just tried and it is working.

<apex:pageBlockTable value="{!lstAccRecords}" var="item" first="{!intPBTFirst}">
     <apex:column >
       <apex:facet name="header">
          <apex:outputPanel >
             <apex:outputText value="Header1"></apex:outputText><br/>
             <apex:outputText value="Header2"></apex:outputText>
          </apex:outputPanel>
        </apex:facet>
        {!item.name}
   </apex:column>
   <apex:column value="{!item.Rating}" />

<apex:pageBlockTable value="{!lstAccRecords}" var="item" first="{!intPBTFirst}">
    <apex:column >
       <apex:facet name="header" >
          <apex:outputText escape="false" value="Header1 <br/> Header2"></apex:outputText>
       </apex:facet>
       {!item.name}
    </apex:column>
    <apex:column value="{!item.Rating}" />
</apex:pageBlockTable>

both examples are working

enter image description here

0
1

I am not sure this is the best solution but hopefully it works for you.

<apex:facet name="header">
    <apex:outputText escape="false" value="Header 1</br> Header 2"></apex:outputText> 
</apex:facet>

Notice that I just put escape="false" in outputtext and .It does display two lines.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .