[SalesForce] How to use colspan in apex:pageBlockSection VF pages

How can I align the same Emp Department fields with the Employee pageBlockSection? I have tried all sort of technics but no success

What I want is simple align with Employee pageblockSection.

Also I have tried in developer console and if I changed from colspan=2 to 4 then its align perfectly the way i wanted but I could not able to make using visualforce page.

enter image description here

Visualforce page:

<apex:pageBlockSection id="pbs" title="Employee" columns="2" >

    <apex:inputField value="{!Employee__c.start_Date__c}"  />
    <apex:inputField value="{!Employee__c.Enrollment__c}" />
    <apex:inputField value="{!Employee__c.end_Date__c}" />
    <apex:inputField value="{!Employee__c.status__c}" />           

    <apex:sectionHeader title="Emp Department"   />
    <br/>

    <apex:pageBlockSection title="Emp Department" id="pbs2" columns="2"   >   
        <apex:inputField value="{!Employee__c.Type__c}"  />
        <apex:inputField value="{!Employee__c.Customer__c}"  />
    </apex:pageBlockSection>   

</apex:pageBlockSection> 

Best Answer

You put a pageBlockSection inside a pageBlockSection. This is what's screwing you up; the second section appears in the first section's left column when you do this. Furthermore, sectionHeader is really meant to be the thing at the top when you're looking at a record. Your code should probably look as follows:

<apex:pageBlock>
    <apex:pageBlockSection id="pbs" title="Employee" columns="2" >
        <apex:inputField value="{!Employee__c.start_Date__c}"  />
        <apex:inputField value="{!Employee__c.Enrollment__c}" />
        <apex:inputField value="{!Employee__c.end_Date__c}" />
        <apex:inputField value="{!Employee__c.status__c}" />           
    </apex:pageBlockSection> 
    <apex:pageBlockSection title="Emp Department" id="pbs2" columns="2"   >   
        <apex:inputField value="{!Employee__c.Type__c}"  />
        <apex:inputField value="{!Employee__c.Customer__c}"  />
    </apex:pageBlockSection>   
</apex:pageBlock>
Related Topic