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
mrhmrh 

Using actionSupport and rerender to change selectable fields

Hello

 

I am having problems trying to rerender a selection of checkbox fields contained within a panelGrid, based on whether another checkbox elsewhere on screen is selected or not.

 

Is what I am trying to do even possible?

 

This is a cutdown version of the code I have.  This is the field (checkbox) definition on which I want to base the other selectable options:

 

<apex:pageBlockSection id="opt1" showHeader="true "title="Options"columns="1">

<apex:inputField value="{Field1__c}"id="f1">

<apex:actionSupport event="onchange" rerender="MoreOptions"/>

</apex:inputField>

</apex:pageBlockSection>

 

This is the section I want to rerender based on the selected value above:

 

<apex:pageBlockSection id="MoreOptions" collapsible="false" showHeader="true" title="Later OptionsSubscriptions" columns="1">

<apex:panelGridcolumns="4"style="width:100%;"styleclass="list"rowclasses="dataRow,dataRow"columnClasses="labelCol,data2Col center,data2Col center,data2Col center">

<apex:outputText value=" "/>

<apex:outputText style="color:#999;font-weight:bold;padding:2px;" value="Option 1"/>

<apex:outputText style="color:#999;font-weight:bold;padding:2px;" value="Option 2"/>

<apex:outputText style="color:#999;font-weight:bold;padding:2px;" value="Option 3"/>

<apex:outputText value="Row 1"/>

<apex:inputField rendered="{!Field1__c}"id="row1opt1_checked" value="{!OptionA__c}"/>

<apex:inputField rendered="{!NOT Field1__c}" id="row1opt1_unchecked" value="{!OptionA_unchecked__c}"/>

<apex:inputField id="row1opt2" value="{!Option2__c}"/>

<apex:inputField id="row1Opt3" value="{!Option3__c}"/>

</apexPanelGrid>

</apex:pageBlockSection>

 

So what i am trying to do is make the first checkbox in row1, column 1 rerender with a different field, checked/unchecked option based on Field1__c being selected or not above.

 

Currently, nothing happens when I select Field1__c.  Nothing is rerendered.

 

Any help would be greatly appreciated.

 

Many thanks,
mark

Best Answer chosen by Admin (Salesforce Developers) 
bob_buzzardbob_buzzard

Rerendering is only carried out after a submit has taken place.  If you want to exclude other parts of the form from the submit you can look at using an apex:actionRegion around that input field.

All Answers

bob_buzzardbob_buzzard

Do you have any required fields in your form that are empty?  That will block the form submission, but as you are only rerendering the pageblocksection you won't see any error messages.

mrhmrh

Hi Bob

 

I was hoping that I use this solution to dynamically update/rerender this section of the form, before submitting it.  Essentially, I need to update 'MoreOptions' before doing a submit.

 

Is this possible?

 

Thanks

Mark

 

 

bob_buzzardbob_buzzard

Rerendering is only carried out after a submit has taken place.  If you want to exclude other parts of the form from the submit you can look at using an apex:actionRegion around that input field.

This was selected as the best answer