0

I want to disable the pageblock section when the checkbox is checked,enable it when the check box is unchecked. I had tried with rerender but it is not working as expected.

Note:The checkbox is placed inside another pageblock

<apex:pageBlock>
   <apex:outputLabel >Payment accepted</apex:outputLabel>

   <apex:inputCheckbox value="{!testCheck }">
      <apex:actionSupport event="onchange" action="{!updateTestCheck}" reRender="casePB" status="statusSaveTrip" />
   </apex:inputCheckbox>
</apex:pageBlock>

<apex:pageBlock id="casePB">
   <apex:outputpanel>
      <apex:outputLabel >Customer Wants:</apex:outputLabel>

      <apex:selectList value="{!Customerselectedid}"  multiselect="false" size="1" >
         <apex:selectOptions value="{!customerwantoptions}"></apex:selectOptions>
         <apex:actionSupport event="onchange" reRender="casePB" action="{!enableCCButton}" status="statusSaveTrip"/>
      </apex:selectlist>

      <apex:commandButton styleClass="btn btn-primary btn-xs"  value="Create Case"  action="{!logACase}" disabled="{!isCaseButton}" status="statusSaveTrip"/>
   </apex:outputpanel>
</apex:pageBlock>
  • Even instead of disable/enable we can hide/show pageblock also. Any pointers on this? – subramanya_C Feb 3 '17 at 6:11
  • Are you changing the value of isCaseButton in your updateTestCheck method? – Caspar Harmer Feb 3 '17 at 6:26
  • Yes @CasparHarmer , i am updating the disabled property of command button only when the checkbox is unchecked. The updtaeTestCheck() is going to execute only when the checkbox is unchecked – subramanya_C Feb 3 '17 at 6:37
  • Can you please check my answer and close this question – Santanu Boral Feb 5 '17 at 19:39
1

I hope that you are changing checkbox values in the controller method.

You can wrap pageblock into an outputPanel and rerender the outputPanel from actionSupport call.

Display the pageblock based on checkbox is checked.

Below is the code:

<apex:pageBlock>
   <apex:outputLabel >Payment accepted</apex:outputLabel>

   <apex:inputCheckbox value="{!testCheck }">
      <apex:actionSupport event="onchange" action="{!updateTestCheck}" reRender="panel1" status="statusSaveTrip" />
   </apex:inputCheckbox>
</apex:pageBlock>

<apex:outputpanel id="panel1" >
<apex:pageBlock id="casePB" rendered={!testCheck}>   
      <apex:outputLabel >Customer Wants:</apex:outputLabel>

      <apex:selectList value="{!Customerselectedid}"  multiselect="false" size="1" >
         <apex:selectOptions value="{!customerwantoptions}"></apex:selectOptions>
         <apex:actionSupport event="onchange" reRender="casePB" action="{!enableCCButton}" status="statusSaveTrip"/>
      </apex:selectlist>

      <apex:commandButton styleClass="btn btn-primary btn-xs"  value="Create Case"  action="{!logACase}" disabled="{!isCaseButton}" status="statusSaveTrip"/>

</apex:pageBlock>
</apex:outputpanel>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.