2

I want an outputfield to have its own row within a pageblocksection.

<apex:pageBlockSection title="SPC" columns="2">

            <tr>
                <td colspan="2">
                    <apex:outputField value="{!accountObject.SPC_Executive_Summary__c}"/> 
                </td>
            </tr>

            <apex:outputField />
            <apex:outputField />
            <apex:outputField />
            <apex:outputField />
            <apex:outputField />


        </apex:pageBlockSection> 

by adding the I kinda got what I wanted but it looks like this: enter image description here

adding a pageBlockSectionItem makes the fields dissapear... enter image description here

     <apex:pageBlockSection title="SPC" columns="2"  rendered="conditions here">

            <!-- CRMT 62903 Start -->
            <apex:pageBlockSectionItem>
                <apex:outputField value="{!accountObject.SPC_Executive_Summary__c}" rendered="{!(!$Setup.Bypass_SPC__c.ByPass__c) && $ObjectType.Account.Fields.SPC_Executive_Summary__c.Accessible}"/> 
            </apex:pageBlockSectionItem>


                <apex:outputField label="SPC Life Discovery" value="{!accountObject.Life_Discovery__c}" rendered="{!(!$Setup.Bypass_SPC__c.ByPass__c) && $ObjectType.Account.Fields.Life_Discovery__c.Accessible}"/>



                <apex:outputField label="SPC Financial Discovery" value="{!accountObject.Financial_Discovery__c}" rendered="{!(!$Setup.Bypass_SPC__c.ByPass__c) && $ObjectType.Account.Fields.Financial_Discovery__c.Accessible}"/>



                <apex:outputField value="{!accountObject.SPC_Client_Segmentation__c}" rendered="{!(!$Setup.Bypass_SPC__c.ByPass__c) && $ObjectType.Account.Fields.SPC_Client_Segmentation__c.Accessible}"/>



                <apex:outputField value="{!accountObject.SPC_Communication_Preference__c}" rendered="{!(!$Setup.Bypass_SPC__c.ByPass__c) && $ObjectType.Account.Fields.SPC_Communication_Preference__c.Accessible}"/>


            <!-- CRMT 62903 Stop -->

        </apex:pageBlockSection>   
5

You can use an empty <apex:pageBlockSectionItem> element to create a "spacer" that takes up one slot in the page block section's field grid.

Is important to remember, in placing the spacer element, that the grid is populated left to right first and then top to bottom. Hence, if you want to fill a row in a two-column layout with a real field on the left and a space on the right, place the empty <apex:pageBlockSectionItem> immediately after the real output field.

You don't need to use any table elements, which I'd regard as an implementation detail.

Here's an example, using all standard fields and the <apex:outputLabel> component you'll need to get your items labeled correctly.

Test230901.vfp

<apex:page standardController="Account">
    <apex:pageBlock>
        <apex:pageBlockSection title="Test" columns="2">
            <apex:pageBlockSectionItem>
                <apex:outputLabel>Name</apex:outputLabel>
                <apex:outputField value="{! Account.Name }"/> 
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem />
            <apex:pageBlockSectionItem>
                <apex:outputLabel>Description</apex:outputLabel>
                <apex:outputField value="{! Account.Description }" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem>
                <apex:outputLabel>Industry</apex:outputLabel>
                <apex:outputField value="{! Account.Industry }" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem>
                <apex:outputLabel>Account Source</apex:outputLabel>
                <apex:outputField value="{! Account.AccountSource }" />
            </apex:pageBlockSectionItem>
            <apex:pageBlockSectionItem>
                <apex:outputLabel>Annual Revenue</apex:outputLabel>
                <apex:outputField value="{! Account.AnnualRevenue }" />
            </apex:pageBlockSectionItem>
        </apex:pageBlockSection>   
    </apex:pageBlock>
</apex:page>

Rendering

Note the blank slot after Name.

Screenshot

  • putting these output fields in pageblocksectionitems makes them disappear – SallyRothroat Aug 31 '18 at 20:05
  • That shouldn't be the case. Can you edit your question to clarify that issue? – David Reed Aug 31 '18 at 20:05
  • didn't mean to do that – SallyRothroat Aug 31 '18 at 20:15
  • No worries, but the answer to that question is no, rendering conditions on the enclosing block won't affect the items except insofar as none of them will be rendered if their enclosing component is not. – David Reed Aug 31 '18 at 20:17
  • I've added an example to clarify the expected structure. – David Reed Aug 31 '18 at 20:52
2

I think, you might use <apex:pageBlockSectionItem>

<apex:pageBlockSection title="SPC" columns="2">
    <apex:pageBlockSectionItem>
        <apex:outputField value="{!accountObject.SPC_Executive_Summary__c}"/>
    </apex:pageBlockSectionItem>
    <apex:pageBlockSectionItem/>

</apex:pageBlockSection> 
  • That could work but I want the fields below to be two to a row – SallyRothroat Aug 31 '18 at 19:19
  • 1
    Then use a pageBlockSectionItem extra. Updated my answer – Santanu Boral Aug 31 '18 at 19:28
  • Could you please show me real quick – SallyRothroat Aug 31 '18 at 19:30

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.