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
John NeffJohn Neff 

How do I display Column Names in a pageBlockTable that has rendered column values?

Hello!

I have created a pageBlockTable, but my column names disappear when I apply the "rendered" tag.  Is there a way that I can statically set the column names so that my table has headers?
 
<apex:pageBlock title="Underfunded Buyers">
    <apex:pageBlockTable value="{!listOfBuyer}" var="by">
            <apex:column value="{!by.Name}" rendered="{! by.Funding_Status__c = 'Funds Needed'}"/>
            <apex:column value="{!by.Spend_Last_Week__c}" rendered="{! by.Funding_Status__c = 'Funds Needed'}"/>
            <apex:column value="{!by.Total_Spend_this_Week__c}" rendered="{! by.Funding_Status__c = 'Funds Needed'}"/>
            <apex:column value="{!by.Forecasted_Spend__c}" rendered="{! by.Funding_Status__c = 'Funds Needed'}"/>
            <apex:column value="{!by.Current_Balance__c}" rendered="{! by.Funding_Status__c = 'Funds Needed'}"/>
             </apex:pageBlockTable>
            </apex:pageBlock>

Thanks!

John
Priya GovindasamyPriya Govindasamy
Hi John,

Try using <apex: column header value> to display header name.
 
<apex:column headerValue="Name" value="{!by.Name}" rendered=.....
 
sfdcdevsfdcdev
You can use <apex:facet> tag inside <apex:column> tag:
 
<apex:page standardController="Account">
    <apex:pageBlock title="Contacts">
        <apex:pageBlockTable value="{!account.Contacts}" var="contact">
            <apex:column >
                <apex:facet name="header">Name</apex:facet>
                        {!contact.Name}
            </apex:column>
            <apex:column >
                <apex:facet name="header">Phone</apex:facet>
                        {!contact.Phone}
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>
</apex:page>