1

so I have a bunch of input fields in PageBlockSectionItems to have inline help text. The problem I'm facing is that I want to have an input field in a different column. The main reason is the only way I can hide a PageBlockSectionItem is to hide the whole row. So if I can specify a column then I can isolate that row.

Example:
InputField1 ------ InputField2
InputField3 ------ InputField4
InputField5 
**InputField6** <--- notice in the same column as above.  

So there could be a few ways to solve this:

1) figure out a way to "hide" with javascript a PageBlockSectionItem OR

2) figure out a way to separate the inline help from the input field and label. Then I could "hide" all the components individually OR

3) be able to specify what fields go into which columns and not use the zig zag pattern

Here is some sample code of 2 PBSI's to give you an idea of what I'm dealing with.

<apex:pageBlockSectionItem HelpText="{!$ObjectType.Application__c.fields.Rpt_Decommission_Status__c.inlineHelpText}">
    <apex:outputLink value="/apex/StatusDefinitions" target="_blank" >Decomission Status</apex:outputLink>
    <apex:inputField value="{!Application__c.Rpt_Decommission_Status__c}" onchange="test(this.value);"/>
</apex:pageBlockSectionItem> 

<apex:pageBlockSectionItem HelpText="{!$ObjectType.Application__c.fields.Agency_Acronym__c.inlineHelpText}">
{!$ObjectType.Application__c.fields.Agency_Acronym__c.label}
<apex:inputField value="{!Application__c.Agency_Acronym__c}" />

3

It's not clear to me what you are trying to do, but here are a couple of points that may help you:

  1. You don't have to have two columns in your pageBlockSection. Two is the default, but you can set the columns attribute to override. Setting it to one would allow you to have a single pageBlockSectionItem per line.

  2. You can't directly choose which column a pageBlockSectionItem appears in, and you cannot override the 'zig-zag' if you use multiple columns, however, you can use an empty pageBlockSectionItem as a placeholder to fill a column with a blank, effectively moving the next field into the next spot in the zig-zag. For example:

    <apex:pageBlockSection columns='2'>
    
      <apex:pageBlockSectionItem helpText='...'>
        <apex:label for='field1'>label1</apex:label>
        <apex:inputText id='field1' value='{!field1}' />
      </apex:pageBlockSectionItem>
      <apex:pageBlockSectionItem /> <!-- placeholder -->
    
      <apex:pageBlockSectionItem helpText='...'>
        <apex:label for='field2'>label2</apex:label>
        <apex:inputText id='field2' value='{!field2}' />
      </apex:pageBlockSectionItem>
    
    </apex:pageBlockSection>
    

    Even though we have 2 columns in the pageBlockSection, the empty pageBlockSectionItem will force field2 to appear under field1, not beside it.

  3. For hiding things, consider using the rendered attribute to selectively show or hide an element, and reRender (on a commandLink, commandButton, actionFunction, or actionSupport element) to allow partial page updates. If you are concerned about the page layout changing when a pageBlockSectionItem is hidden, use them in pairs: one that renders normally, and an empty one that renders if the first one doesn't. For example:

    <apex:pageBlockSection columns='2'>
    
      <apex:pageBlockSectionItem rendered='{!showField1}' helpText='...'>
        <apex:label for='field1'>label1</apex:label>
        <apex:inputText id='field1' value='{!field1}' />
      </apex:pageBlockSectionItem>
      <apex:pageBlockSectionItem rendered='{!NOT(showField1}' /> <!-- placeholder -->
    
      <apex:pageBlockSectionItem helpText='...'>
        <apex:label for='field2'>label2</apex:label>
        <apex:inputText id='field2' value='{!field2}' />
      </apex:pageBlockSectionItem>
    
    </apex:pageBlockSection>
    

    In this example, field1 appears in the left column when showField1 is true, but field2 always remains in column2 due to the placeholder that appears when field1 is hidden.

  • Option 2 works perfect. What a robust answer! Thank you so much! – tjcinnamon Jan 27 '16 at 18:56

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.