+ Start a Discussion
Yuvraj Ganesan 15Yuvraj Ganesan 15 

Render pageblocksection on selection of mutliselect picklist value

Hi All,
I need to show display the pageblocksection based on multiselect picklist chosen.
Say for the example, I have the custom multipicklist field in contact object, where the values are one, two, three.
Whenever i choose "One" Option corresponding page block must be showned.
 
<apex:page standardController="Contact" showHeader="false">
    <apex:pageBlock >
        <apex:pageBlockSection >
            <apex:inputField value="{!contact.Choose_Number__c}">
                <apex:actionSupport event="onchange" reRender="prd" />
            </apex:inputField>
        </apex:pageBlockSection>
        <apex:pageBlockSection title="Product Test" id="prd" rendered="{!contact.Choose_Number__c == 'One'}">
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>

Whenever i choose or Move "One" option from Available to Chosen, Pageblocksection need to be display. 
 
Best Answer chosen by Yuvraj Ganesan 15
yogesh_sharmayogesh_sharma

Hello Yuvraj,

Try this one:

<apex:page standardController="Contact" showHeader="false">
    <apex:form>
        <apex:pageBlock >
              <apex:pageBlockSection >
                    <apex:inputField value="{!contact.Choose_Number__c}">
                           <apex:actionSupport event="onchange" reRender="abcd" />
                   </apex:inputField>
            </apex:pageBlockSection>

       <apex:outputPanel id="abcd">
                    <apex:pageBlockSection title="Product Test" id="prd"  rendered="                           {!IF(contact.Choose_Number__c == 'One',false,true)}">
             </apex:pageBlockSection>
      </apex:outputPanel>
      </apex:pageBlock>
   </apex:form>
</apex:page>


I hope it helps you.

Thanks,

Yogesh Sharma
 

All Answers

Ravi Dutt SharmaRavi Dutt Sharma
Try to reRender the apex:pageBlock instead of apexPageBlockSection
 
<apex:page standardController="Contact" showHeader="false">
    <apex:pageBlock >
        <apex:pageBlockSection id="prd">
            <apex:inputField value="{!contact.Choose_Number__c}">
                <apex:actionSupport event="onchange" reRender="prd" />
            </apex:inputField>
        </apex:pageBlockSection>
        <apex:pageBlockSection title="Product Test"  rendered="{!contact.Choose_Number__c == 'One'}">
        </apex:pageBlockSection>
    </apex:pageBlock>
    </apex:form>
</apex:page>
Let me know if this helps. Thanks.
 
yogesh_sharmayogesh_sharma

Hello Yuvraj,

Try this one:

<apex:page standardController="Contact" showHeader="false">
    <apex:form>
        <apex:pageBlock >
              <apex:pageBlockSection >
                    <apex:inputField value="{!contact.Choose_Number__c}">
                           <apex:actionSupport event="onchange" reRender="abcd" />
                   </apex:inputField>
            </apex:pageBlockSection>

       <apex:outputPanel id="abcd">
                    <apex:pageBlockSection title="Product Test" id="prd"  rendered="                           {!IF(contact.Choose_Number__c == 'One',false,true)}">
             </apex:pageBlockSection>
      </apex:outputPanel>
      </apex:pageBlock>
   </apex:form>
</apex:page>


I hope it helps you.

Thanks,

Yogesh Sharma
 

This was selected as the best answer
Yuvraj Ganesan 15Yuvraj Ganesan 15
Thanks Yogesh. Your logic worked for me. 
yogesh_sharmayogesh_sharma

Yuvraj,

Your welcome...!!!