1

I wrote a visualforce page using a wrapper class. Everything is displaying just the way I want it for the most part. I was trying to figure out how to display columns within my pageblock on conditions however my format gets all messed up. I was referencing this: https://www.forcetalks.com/salesforce-topic/how-can-we-create-a-dynamic-checkbox-on-visualforce-page/ however when I try to use the pageblockSectionItem Rendered un-formats my 3rd page block section and makes it all smashed together and some fields do not display. What I want to do is if H.Found__c = yes then display some additional fields from my lstHost(which is an object that I am querying. )

I can show my controller if need be. Any help would be appreciated.

<apex:page sidebar="false" standardController="Quote__c" extensions="FormExtension" showHeader="true">
<apex:form >



<apex:pageBlock >
        <apex:pageblocksection columns="2">

            <apex:outputField value="{!Quote__c.name}"/>
            <apex:outputField value="{!Quote__c.Status__c}"/> 

        </apex:pageBlockSection>

    <apex:pageBlockTable value="{!records}" var="Q"> 
   <apex:column >

         <apex:pageblockTable value="{!Q.lstHost}" var="H">
                <apex:column value="{!H.Name}"/>
                <apex:column value="{!H.Product_Brand__c}"/>

                <apex:column> 
                <apex:inputField value="{!H.Found__c}" required="true">
                </apex:inputField> 
                </apex:column>

                <apex:column >

                        <apex:pageBlockTable value="{!H.Assets__r}" var="A">
                            <apex:column value="{!A.Brand__c}"/>
                            <apex:column value="{!A.Model__c}"/>

                              <apex:column value="{!A.Order__c}"/>
                            <apex:column value="{!A.SerialNumber}"/>

                        </apex:pageBlockTable>
                </apex:column>
            </apex:pageblockTable>
        </apex:column>

</apex:pageBlockTable> 
</apex:pageBlock>

<apex:pageBlock >  
      <apex:pageBlockSection columns="1">
     <apex:pageBlockTable value="{!AFields}" var="Additional">

        <apex:column headerValue="Product">
            <apex:inputField value="{!Additional.Product__c}"/>
        </apex:column>
          <apex:column headerValue="End Config">
            <apex:inputField value="{!Additional.End_Config__c}" style="width:95%;"/>
        </apex:column>
         <apex:column headerValue="Current Configuration">
            <apex:inputField value="{!Additional.Config__c}" style="width:95%;"/>
        </apex:column>


    </apex:pageBlockTable>
     </apex:pageBlockSection>

1
  • Some useful debugging tips: Make sure you're rerendering a apex:pageMessages with your rerenders. Any problems will be reported instead of silently ignored. Use immediate=true to avoid hitting the "required fields" problem. (Submitting a page to the server will fail if you have required fields on the page. You wont see an error message unless you renrender those field /the page messages). Jul 9, 2018 at 14:55

1 Answer 1

4

You could remove apex:PageBlockSection and then add rendered condition in apex:column for 3rd pageBlockTable as follows

<apex:pageBlock>  
     <apex:pageBlockTable value="{!AFields}" var="Additional">
        <apex:column headerValue="Product">
            <apex:inputField value="{!Additional.Product__c}"/>
        </apex:column>
          <apex:column headerValue="End Config">
            <apex:inputField value="{!Additional.End_Config__c}" style="width:95%;"/>
        </apex:column>
         <apex:column headerValue="Current Configuration" rendered={!your condition}">
            <apex:inputField value="{!Additional.Config__c}" style="width:95%;"/>
        </apex:column>
    </apex:pageBlockTable>
</apex:pageBlock>
4
  • <apex:column> <apex:inputField id="xxxif1" value="{!H.Found__c}" required="true"> </apex:inputField> </apex:column> <apex:column headerValue="Current Configuration" rendered=" {!IF(H.Found__c='Yes',true,false)}"> <apex:inputField value="{!H.Name}" style="width:95%;"/> </apex:column>
    – Brooke
    Jul 9, 2018 at 13:54
  • I tried the above but if Yes is selected nothing happens
    – Brooke
    Jul 9, 2018 at 13:55
  • O i bet it is because it is an input value.
    – Brooke
    Jul 9, 2018 at 14:22
  • 1
    I've solved this in the past by setting up a actionSupport on the onchange event of the field (Found__c). When the value is changed, you set the value on the server side to whatever value was provided in the input, and then rerender the condition. The rerender will use the value from the server, so we need to make sure its got the right value. Jul 9, 2018 at 14:40

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .