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

Using VF to display two columns of data in a page layout


I'm using the following VF to display a number of fields in two columns on a page layout:

<apex:page standardController="CW_Order_Line__x" extensions="OrderLine_ShipToInfoCtrlExt" readOnly="true">
<apex:pageBlock >
<apex:pageBlockSection columns="2">
<div class="row">
<div class="col-md-6">
<apex:outputField label="Name" value="{!shipToInfo.Name__c}"/>
<apex:outputField label="Address" value="{!shipToInfo.Ship_to_Address__c}"/>
<div class="col-md-6">
<apex:outputField label="Day Phone" value="{!shipToInfo.Ship_to_Day_Phone__c}"/>
<apex:outputField label="Night Phone" value="{!shipToInfo.Ship_to_Night_Phone__c}"/>
<apex:outputField label="Email" value="{!shipToInfo.Ship_to_Email__c}"/> </div>

I am getting the data displayed in two columns but the fields are being rendered aphabetically rather than as specified in the code above.

What I'm getting is:

Column 1: Address, Day Phone, Email
Column 2: Name, Night Phone

What I want is:

Column 1: Name, Address
Column 2: Day Phone, Night Phone, Email

Thanks in advance!

When you use pageBlocSection with columns, salesforce introduces a table with four columns
Try without the pageblocksection.
Commented out the pageBlockSection pieces but now the data is being rendered on the left hand side of the page with no labels.

The following got me to where I needed to be:

<apex:page standardController="CW_Order_Line__x" extensions="OrderLine_ShipToInfoCtrlExt" readOnly="true"> <apex:pageBlock > <apex:pageBlockSection columns="2"> <apex:outputField label="Name" value="{!shipToInfo.Name__c}"/> <apex:outputField label="Day Phone" value="{!shipToInfo.Ship_to_Day_Phone__c}"/> <apex:outputField label="Address" value="{!shipToInfo.Ship_to_Address__c}"/> <apex:outputField label="Night Phone" value="{!shipToInfo.Ship_to_Night_Phone__c}"/> <apex:pageBlockSectionItem > <!-- empty selectItem--> </apex:pageBlockSectionItem> <apex:outputField label="Email" value="{!shipToInfo.Ship_to_Email__c}"/> </apex:pageBlockSection> </apex:pageBlock> </apex:page>