I am using actionRegion for to show/hide the fields based upon picklist in Opportunity. When i am selecting the Stage picklist value is Closed Lost, then 4 text fields will be displays. It works fine. but the fields will not shown properly. what is the solution for to show these fields properly as like as remaining fields. Here i am attached the image to understand clearly.
Here i provided my code.
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="save & New" action="{!quicksave}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection title="Opportunity information" columns="2">
<apex:pageBlockSectionItem >
<apex:outputLabel > Opportunity Owner</apex:outputLabel>
{!$User.FirstName} {!$User.LastName}
</apex:pageBlockSectionItem>
<apex:inputField value="{!opportunity.CloseDate}"/>
<apex:inputField value="{!opportunity.Name}"/>
<apex:pageblockSectionItem >
<apex:outputLabel value="Stage"/>
<apex:actionRegion >
<apex:inputField value="{!Opportunity.StageName}">
<apex:actionSupport event="onchange" reRender="ajaxrequest" />
</apex:inputField>
</apex:actionRegion>
</apex:pageblockSectionItem>
<apex:inputField value="{!opportunity.AccountId}"/>
<apex:inputField value="{!opportunity.Probability}"/>
<apex:inputField value="{!opportunity.Type}"/>
<apex:inputField value="{!opportunity.Amount}"/>
<apex:inputField value="{!opportunity.ForecastCategoryName}"/>
<apex:inputField value="{!opportunity.Sales_Office__c}"/>
<apex:inputField value="{!opportunity.CampaignId}"/>
<apex:inputField value="{!opportunity.UI_Code__c}"/>
<apex:inputField value="{!opportunity.CurrencyIsoCode}"/>
<apex:inputField value="{!opportunity.Jobsite_Location__c}"/>
<apex:inputField value="{!opportunity.LeadSource}"/>
<apex:outputPanel id="ajaxrequest">
<apex:pageblockSection rendered="{!Opportunity.StageName=='Closed Lost'}" >
<apex:inputField value="{!opportunity.Reason_for_Loss__c}"/>
<apex:inputField value="{!opportunity.Lost_To_whom__c}"/>
<apex:inputField value="{!opportunity.Competitor_s_Price__c}"/>
<apex:inputField value="{!opportunity.Competitor_s_MT__c}"/>
</apex:pageblockSection>
</apex:outputPanel>
</apex:pageBlockSection>
<apex:pageBlockSection title="Additional Information" columns="2">
<apex:inputField value="{!opportunity.NextStep}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Description Information" columns="2">
<apex:inputField value="{!opportunity.Description}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
Best Answer
Referring to the Reference apex:actionSupport, an example can be constructed:
For the example, make sure to give the VF Page a valid Opportunity Id like
Controller:
VF Page: