You need to sign in to do that
Don't have an account?
Rick MacGuigan
Rerender & actionSupport problem with section collapsing
This code renders the Other_Policy_term__c visible if the user chooses 'other' from a picklist called Policy_Term__c . However, I have a script function that collapses the page block section on load. This actionSupport event causes the pageblock section to collapse . How can I update the field leaving the section expanded ?
<apex:page standardController="Auto_Audit_Sample_Policy__c" readOnly="false" >
<apex:variable var="a" value="{!Auto_Audit_Sample_Policy__c}" />
<apex:variable var="PolicyTerm" value="{!a.Policy_Term__c}" />
<apex:form id="form1">
<apex:pageBlock id="block1" title="Auto Policy" >
<apex:outputPanel id="ajaxrequest" >
<apex:pageBlockSection columns="1" id="section1" title="Policy Information" rendered="{!PolicyInformation=true}">
<apex:inputField value="{!a.Policy_Term__c}" >
<apex:actionSupport event="onchange" reRender="section1" />
</apex:inputField>
<apex:inputField id="fieldtest" value="{!a.Other_Policy_term__c}" rendered="{!PolicyTerm="other"}" />
<script>twistSection(document.getElementById("{!$Component.section1}").childNodes[0].childNodes[0]); </script>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:page standardController="Auto_Audit_Sample_Policy__c" readOnly="false" >
<apex:variable var="a" value="{!Auto_Audit_Sample_Policy__c}" />
<apex:variable var="PolicyTerm" value="{!a.Policy_Term__c}" />
<apex:form id="form1">
<apex:pageBlock id="block1" title="Auto Policy" >
<apex:outputPanel id="ajaxrequest" >
<apex:pageBlockSection columns="1" id="section1" title="Policy Information" rendered="{!PolicyInformation=true}">
<apex:inputField value="{!a.Policy_Term__c}" >
<apex:actionSupport event="onchange" reRender="section1" />
</apex:inputField>
<apex:inputField id="fieldtest" value="{!a.Other_Policy_term__c}" rendered="{!PolicyTerm="other"}" />
<script>twistSection(document.getElementById("{!$Component.section1}").childNodes[0].childNodes[0]); </script>
</apex:pageBlockSection>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>
All Answers
Is there a way around loosing the field label when wrapping the actionRegion around the inputField ?
<apex:page standardController="Auto_Audit_Sample_Policy__c" readOnly="false" >
<apex:variable var="a" value="{!Auto_Audit_Sample_Policy__c}" />
<apex:variable var="PolicyTerm" value="{!a.Policy_Term__c}" />
<apex:form id="form1">
<apex:pageBlock id="block1" title="Auto Policy" >
<apex:outputPanel id="ajaxrequest" >
<apex:pageBlockSection columns="1" id="section1" title="Policy Information" rendered="{!PolicyInformation=true}">
<apex:actionRegion >
<apex:inputField value="{!a.Policy_Term__c}" >
<apex:actionSupport event="onchange" reRender="section1" />
</apex:inputField>
<apex:inputField id="fieldtest" value="{!a.Other_Policy_term__c}" rendered="{!PolicyTerm="other"}" />
</apex:actionRegion >
</apex:pageBlockSection>
<script>twistSection(document.getElementById("{!$Component.section1}").childNodes[0].childNodes[0]); </script>
</apex:outputPanel>
</apex:pageBlock>
</apex:form>
</apex:page>