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
WycadoWycado 

Dynamically displaying page layout section

I'm just getting into writing VF custom pages. I want to display a standard page layout on an object called "Referrer__c" UNLESS a custom field called "IR__c" on a record is checked. If it is checked, I want to display 2 other fields - "ES__c" and "BZ__c", and a section called "IR Information".

 

I'm unsure on how to get this conditional logic in here. Thus far I have this, but I'm unclear on how to make this display the "IR Information" section and the two fields ONLY if the "IR__c" is checked.

 

Any help would be most appreciated.

 

<apex:page standardController="Referrer__c">
    <apex:detail />
       <apex:actionSupport event="onchange" rerender="IRInformation"/>    
</apex:page>
Deepak Kumar ShyoranDeepak Kumar Shyoran

Hi,

 

You can display a page layout section by using a "rendered" attribute of apex component. For that you need to create  a apex:outputPannel and then set the rendered attribute for checked condition of your check box in following manner

 

//Set according to value of checkbox some times it's value in on and sometime 1 for checked

<apex:outputPanel rendered="{!If(Referrer__c.IR__c == 1, true,false)}"  >

<!--  put your section inside this panel -->

</apex:outputPanel>

 

and then rerender the parent of this outputPanel not this outputPanel.

 

Please give kudus by hitting on star if this post help you and mark my post as a answer for your question so that it will be available as a solution for other for same type of problem .

WycadoWycado

I'm getting closer  but my code is getting errors and I don't know this well enough to figure out my error.

 

<apex:page standardController="Referrer__c">
    <apex:detail />
       <apex:outputPanel rendered="{!If(Referrer__c.IR__c == 1, true,false)}">
       <apex:section="IRInformation"/>
</apex:outputPanel>
</apex:page>

 

I get the error "The prefix "pex" for attribute "pex:section" associated iwth an element type "a" is not bound in ReferrerCustomPage at line 4

 

and

"The prefiex "pex" for attribute "pex"section" associated with an elemment type "a" is not bound.   These are due to some type of structure error that is not reading the word "apex"

Deepak Kumar ShyoranDeepak Kumar Shyoran

This error is shown because Visualforce doesn't have a <apex:section> component <!--  put your section inside this panel --> from this line my mean is not to use <apex:section> inside this rather to use your visualforce component like <apex:outputField /> , <apex:outputText /> ,<apex:pageblockSection /> which ever component you are using so that it get refrshed with the help reRendering attribute. 

 

IRInformation this must be Id of a section which you want to show dynamically. Just put your code inside below code.

<apex:outputPanel id="IRInformation" >

<apex:outputPanel rendered="{!If(Referrer__c.IR__c == 1, true,false)}"  >

<!--  put your code here this panel -->

</apex:outputPanel>

<apex:outputPanel>

 

now reRender this IRInformation from your code.

 

Please don't simply copy paste the code read it carefully and modify it according to your need and for more details on visualforce component and their attribute please visit http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#CSHID=pages_compref_pageBlockSection.htm|StartTopic=Content%2Fpages_compref_pageBlockSection.htm|SkinName=webhelp

 

 

Please give kudus by hitting on star if this post help you and mark my post as a answer for your question so that it will be available as a solution for other for same type of problem