0

In this VF page, only the year__c column has a label showing. The other columns don't show a label. How to get the columns to show labels? (see pic for a visual)enter image description here

[![<apex:page standardController="Community_Yearly_Plan__c" extensions="vf_CommunityPlanGoalPSetting_Cntrlr" cache="false">

    <apex:form >
        <apex:pageblock >
            <apex:pageBlockSection title="Community Plan Setting Goals" columns="1" id="pbsCon" >
                <apex:outputPanel id="panelCon">
                    <div id="loading-curtain-div"/>

                    <apex:pageBlockTable id="pbtCon" value="{!listGoalsCurrYear}" var="cpgs">

                        <apex:column value="{!cpgs.Year__c}" />                        
                        <apex:column>
                            <apex:inputField id="ft" value="{!cpgs.Funding_Type__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   
                        <apex:column>
                            <apex:inputField id="ccp" value="{!cpgs.Core_Current_Participation__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True'  || newRow ="nr",'True','False')}" />
                        </apex:column>   

                        <apex:column style="width:10px;">
                            <apex:inputField id="fa" value="{!cpgs.Funding_Amount__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   
                        <apex:column >
                            <apex:inputField id="fd" value="{!cpgs.Funding_Description__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   
                        <apex:column style="width:10px;">
                            <apex:inputField id="ga" value="{!cpgs.Goal_Amount__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   
                        <apex:column >
                            <apex:inputField id="gac" value="{!cpgs.Goal_Amount_Comments__c}" rendered="{!IF(cpgs.EditableOrReadOnly__c='True' || newRow ="nr",'True','False')}" />
                        </apex:column>   

                    </apex:pageBlockTable>

                    <apex:commandButton style="align:center;" action="{!AddRow}" value="Add Funding Record" reRender="pbsCon" />
                    <apex:commandButton style="align:center;" action="{!SaveRecords}" value="Save" reRender="pbsCon" />                    

                </apex:outputPanel>

                <apex:outputPanel id="panelCon2">
                    <div id="loading-curtain-div"/>

                    <apex:pageBlockTable id="pbtCon2" value="{!listGoalsPrevYears}" var="cpgs2">

                        <apex:column value="{!cpgs2.Year__c}" />                        
                        <apex:column>
                            <apex:outputField value="{!cpgs2.Funding_Type__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />                            
                        </apex:column>   
                        <apex:column>
                            <apex:outputField value="{!cpgs2.Core_Current_Participation__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />                            
                        </apex:column>   
                        <apex:column>
                            <apex:outputField value="{!cpgs2.Funding_Amount__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />                            
                        </apex:column>   
                        <apex:column >
                            <apex:outputField value="{!cpgs2.Funding_Description__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />
                        </apex:column>   
                        <apex:column >
                            <apex:outputField value="{!cpgs2.Goal_Amount__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />
                        </apex:column>   
                        <apex:column >
                            <apex:outputField value="{!cpgs2.Goal_Amount_Comments__c}" rendered="{!IF(cpgs2.EditableOrReadOnly__c!='True','True','False')}" />
                        </apex:column>   

                    </apex:pageBlockTable>

                </apex:outputPanel>                
            </apex:pageBlockSection>
        </apex:pageblock>
    </apex:form>
</apex:page>][1]][1]
1

This is because when you specify the value attribute of a column to be an SObject field, the component automatically creates the header label.

From https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_compref_column.htm

Note that if you specify an sObject field as the value attribute for an <apex:column>, the associated label for that field is used as the column header by default.

Where you are creating your own custom column contents, you need to use the header facet to specify your header:

<apex:column style="text-align:center">
    <apex:facet name="header">Label</apex:facet> 
    <apex:inputField .... />
</apex:column>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.