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
bathybathy 

How to rerender a panel grid on a visual force page based on a picklist value

Hi Guys,

Stuck with a problem in visual force page. Not able to rerender a panel grid based on the value of a picklist. I have a picklist field with Yes/No options. I want to display the panel grid if the answer to the question is 'Yes' and hide if it is 'No'.

I am giving my code snippet here. Please help
<apex:Outputlabel Value="Cash and Fixed Interest Investments" />
         <apex:ActionRegion >
          <apex:InputField value="{!lf.Cash_and_Fixed_Interest__c}" >  <apex:actionSupport event="onchange" rerender="thegrid3" /> </apex:InputField>    // This is Yes/No Question. Grid must be displayed if the answer to this question is "Yes"                                                                                                                                                                                                         
    </apex:ActionRegion>

//This is my code to display the panel grid b checking the value of the piclist field

<apex:ActionRegion>
     <apex:PanelGrid columns="8" id="thegrid3" width="12.5%" rendered="{!IF(lf.Cash_and_Fixed_Interest__c =='Yes',True,False)}" >
The grid is not displayed even if I select Yes from the picklist. Any ideas why the rerender is not working in the action support. I am pasting the screenshots of the result VF page.

This is when page loads initially:
User-added image

No change if I select 'Yes' in the picklist:
User-added image
Any help is greatly appreciated.

Thanks,
Bathy.
 
JayantJayant
Rerender in actionSupport can only rerender a component to which its related.
e.g. if you have 2 blocks independent of each other, block1 and block2. And a commandButton in block1 says event="onchange" rerender="block2", it won't work. To resolve, take an outputPanel and make both blocks children of this panel and set rerender as  - rerender="panel1" and it should work.