Monday, 18 March 2013

onChange of Pick list value Another Page block section should be Rendered

Hi,
 Create VF page , i.e onChange of pick list value Stage to 'closed lost' Another page block section should visible, if you select another stage value it should be hide.

See the code below,

  <apex:page standardController="Opportunity" sidebar="false">
    <apex:sectionHeader title="Edit Opportunity" subtitle="{!opportunity.name}"/>
    <apex:form >
        <apex:pageBlock title="Edit Opportunity" id="thePageBlock" mode="edit">
            <apex:pageMessages />
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}"/>
                <apex:commandButton value="Cancel" action="{!cancel}"/>                
            </apex:pageBlockButtons>
            <apex:actionRegion >
                <apex:pageBlockSection title="Basic Information" columns="1">
                    <apex:inputField value="{!opportunity.name}"/>
                    <apex:pageBlockSectionItem >
                        <apex:outputLabel value="Stage"/>
                        <apex:outputPanel >
                            <apex:inputField value="{!opportunity.stageName}">
                                <apex:actionSupport event="onchange" rerender="thePageBlock"
                                                    status="status"/>
                            </apex:inputField>
                            <apex:actionStatus startText="applying value..." id="status"/>
                        </apex:outputPanel>
                    </apex:pageBlockSectionItem>
                    <apex:inputField value="{!opportunity.amount}"/>
                    
                </apex:pageBlockSection>
            </apex:actionRegion>

 <!-- This is another page block section , it visible when stage is 'closed lost' --> 
            <apex:pageBlockSection title="Closed Lost Information" columns="1"
                                   rendered="{!opportunity.stageName == 'Closed Lost'}">
                <apex:inputField value="{!opportunity.closedate}"/>
                <apex:inputField value="{!opportunity.amount}"/>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

No comments:

Post a Comment