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
JasonRogersJasonRogers 

pageBlockTable headers disappear when using outputField in a column

Code:
<apex:page standardController="Account">
  <apex:pageBlock title="Opportunities">
    <apex:form >
        <apex:pageBlockTable value="{!account.Opportunities}" var="opty">
          <apex:column >
            <apex:commandLink rerender="detail">
              <apex:param name="opty_id" value="{!opty.id}" />
              <apex:param name="render_details" value="true" />
              {!opty.Name}
            </apex:commandLink>
          </apex:column>
          <apex:column value="{!opty.StageName}"/>
          <apex:column value="{!opty.Type}"/>
          <apex:column value="{!opty.CloseDate}"/>
          <apex:column value="{!opty.License_Start_Date__c}"/>
          <apex:column value="{!opty.ExpirationDate__c}"/>
          <apex:column value="{!opty.Rollup_Amount__c}"/>
          <apex:column value="{!opty.Rollup_New_Amount__c}"/>
          <apex:column value="{!opty.Rollup_Renew_Amount__c}"/>
          <apex:column value="{!opty.Rollup_One_Time_Amount__c}"/>
          <apex:column value="{!opty.Owner.Name}"/>
          <apex:column value="{!opty.Active_Status__c}"/>
        </apex:pageBlockTable>
    </apex:form>
  </apex:pageBlock>
  <apex:outputPanel id="detail">
    <apex:actionStatus startText="Looking up Opportunity...">
      <apex:facet name="stop"> 
        <apex:detail subject="{!$CurrentPage.parameters.opty_id}" relatedList="false" title="false" rendered="{!$CurrentPage.parameters.render_details}" />
      </apex:facet>
    </apex:actionStatus>
  </apex:outputPanel>  
  <!-- End Default Content REMOVE THIS -->
</apex:page>
 In the above code, I am just trying to create an alternative opportunities related list for accounts adding in as many fields as we would like.  When I use the apex:column elements with date fields the values output are in a long date format (with time and timezone).  If I put an apex:outputField in the apex:column the date is formatted in short format but then the header disappears. Is there any way to format date fields in an apex:pageBlockTable element as short form and keep the header of the column? I have tried using the header attribute in the column as well, but to no avail.
kmccollkmccoll
You can use headerValue in the column tag to explicitly specify a header and it should work.  The header facet does not work right now (think this is a known bug).
jwetzlerjwetzler
correct.  And it is also a known bug that column value renders the value attribute as a String, and not formatted the way outputField does it.

The bug with header facets should be fixed very soon.

However as mentioned you should be able to use headerValue="Date" on the column, and instead of value, but an outputField in the column.
JasonRogersJasonRogers
Code:
          <apex:column headerValue="Expiration">
            <apex:outputField value="{!opty.ExpirationDate__c}" />
          </apex:column>

 Thanks.  Using the above approach indeed worked.  Now, if we could only do that on currency fields as well!