[SalesForce] Rerender outputpanel on command button click

<apex:commandButton value="SDS Account" action="{!fetchSDSAccountDetails}" 
    styleClass="btn btn-primary btn-sm" 
    reRender="pbstracc,pbssdsacc" status="sdsAccButton"/> 

<apex:outputPanel id="pbssdsacc">
    <apex:pageBlockSection rendered="{!sdsAccount}" columns="2" >
        <apex:outputText label="Customer" value="{!customerDetails.Name}"/>
        <apex:outputText label="Customer Code" 
            value="{!customerDetails.KUNNR__c}"/>
        <apex:outputText label="Address" 
            value="{!customerDetails.Street_1__c} 
                   {!customerDetails.Street_1__c} 
                   {!customerDetails.Street_2__c} 
                   {!customerDetails.Town__c} 
                   {!customerDetails.State__c} 
                   {!customerDetails.District__c} 
                   {!customerDetails.PIN_code__c}"/><br/>
        <apex:input type="date" label="From Date " 
            value="{!accountFromDate}" style="width:120px;font-size:12px" />
        <apex:input type="date" label="To Date " 
            value="{!accountToDate}" style="width:120px;font-size:12px" />
        <apex:commandButton value="Generate Report" 
            action="{!generateSDSAccountDetails}" 
            styleClass="btn btn-primary btn-sm" reRender="pbssdsacc"/>
    </apex:pageBlockSection> 
    <apex:outputPanel>
        <apex:pageBlockSection rendered="{!sdsAccountGenerateReport}">
            Customer Name
        </apex:pageBlockSection>
    </apex:outputPanel>                                 
</apex:outputPanel> 

Onclick of SDS Account button I want to rerender pbssdsacc which is working fine. But on click of Generate Report I want to show the pageblock section which is not displayed on click of SDS Account button but displayed on click of Generate Report button

Best Answer

You need following change to your code. You need to give id to parent outputPanel of your pageBlockSection

<apex:outputPanel id="pageBlockSectionParentDiv">
    <apex:pageBlockSection rendered="{!sdsAccountGenerateReport}">
        Customer Name
    </apex:pageBlockSection>
</apex:outputPanel>                                 

and then you should use that id in rerender comma separated list

<apex:commandButton value="Generate Report" 
        action="{!generateSDSAccountDetails}" 
        styleClass="btn btn-primary btn-sm" reRender="pbssdsacc,pageBlockSectionParentDiv"/>

Please vote up and mark answer as accepted if this works for you

Related Topic