0

One of my fields below won't align to a PageBlockSection. What am I doing wrong here?

 <apex:pageBlockSection title="Advertiser" collapsible="true" columns="1" id="advertiser">    
                <apex:repeat value="{!$ObjectType.Advertiser__c.FieldSets.flowAdvertiserCreate}" var="f">
                  <apex:inputField value="{!Advertiser[f]}" required="{!OR(f.required, f.dbrequired)}" rendered="{!Advertiser.Id == null}" />
                  <apex:outputField value="{!Advertiser[f]}" rendered="{!Advertiser.Id != null}" />            
               </apex:repeat>
                <apex:inputField value="{!Opp.Advertiser__c}" required="true"/>
            </apex:pageBlockSection>

            <apex:pageBlockSection title="Campaign Detail" collapsible="true" columns="2">
                <apex:repeat value="{!$ObjectType.Opportunity.FieldSets.AXCampaignDetail}" var="f">
                  <apex:inputField value="{!Opp[f]}" required="{!OR(f.required, f.dbrequired)}"/>
               </apex:repeat>
               <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>

             <apex:pageblockSectionItem>
                 <apex:outputLabel>Plan contains STB/VOD,OTT/CTV, Linear?</apex:outputLabel>
                     <apex:actionRegion >
                         <apex:inputField value="{!Opp.PlanContains__c}" label="Plan contains STB/VOD,OTT/CTV, Linear?" required="true">
                             <apex:actionSupport event="onchange" action="{!null}" rerender="op0"/>
                         </apex:inputField>
                     </apex:actionRegion>
             </apex:pageblockSectionItem>

             <apex:pageBlockSectionItem ></apex:pageBlockSectionItem>

             <apex:pageBlockSection id="op0" columns="2" >
                <apex:pageblockSectionItem rendered="{!Opp.PlanContains__c=='OTT/CTV'}">
                    <apex:outputLabel style="color:red;font-size:12px;font-weight:750">Incremental Reach</apex:outputLabel>
                        <apex:actionRegion >
                            <apex:inputField value="{!Opp.IncrementalReach__c}" style="color:red;" label="Incremental Reach"/>
                        </apex:actionRegion> 
                </apex:pageblockSectionItem>
                </apex:pageBlockSection>

               <apex:pageBlockSectionItem></apex:pageBlockSectionItem>

                    <apex:pageblockSectionItem >
                        <apex:outputLabel >Additional Targeting</apex:outputLabel>
                            <apex:actionRegion >
                                <apex:inputField value="{!Opp.Additional_Targeting__c}" label="Addl Targeting" required="true">
                                    <apex:actionSupport event="onchange" action="{!null}" rerender="op1,op3"/>
                                </apex:inputField>
                            </apex:actionRegion>
                    </apex:pageblockSectionItem>
               </apex:pageBlockSection>

            <apex:pageBlockSection id="op1" columns="1" >
                <apex:pageblockSectionItem rendered="{!Opp.Additional_Targeting__c== 'Nielsen Marketing Cloud Data Segment'}">
                    <apex:outputLabel style="color:red;font-size:12px;font-weight:750">Desired Audience</apex:outputLabel>
                        <apex:actionRegion >
                            <apex:inputField value="{!Opp.DesiredAudience__c}" style="color:red;" label="Desired Audience"/>
                        </apex:actionRegion> 
                </apex:pageblockSectionItem>
               </apex:pageBlockSection>

            <apex:pageBlockSection id="op3" columns="1" >
                <apex:pageblockSectionItem rendered="{!OR(Opp.Additional_Targeting__c== 'Nielsen DAR Measurement',Opp.Additional_Targeting__c== 'DAR Demo Guarantee')}">
                    <apex:outputLabel style="color:red;font-size:12px;font-weight:750">Demo Bands</apex:outputLabel>
                        <apex:actionRegion >
                            <apex:inputField value="{!Opp.DemoBands__c}" style="color:red;" label="Desired Audience"/>
                        </apex:actionRegion> 
                </apex:pageblockSectionItem>
               </apex:pageBlockSection>

enter image description here

1 Answer 1

0

The reason it is not aligning properly is because you have included a PageBlockSection inside a PageBlockSection.You have included an additional PageBlockSection for IncrementalReach__c, either remove that PageBlockSection or include OutputPanel in it, and it should align properly.

Replace the below code

<apex:pageBlockSection id="op0" columns="2" >
    <apex:pageblockSectionItem rendered="{!Opp.PlanContains__c=='OTT/CTV'}">
        <apex:outputLabel style="color:red;font-size:12px;font-weight:750">Incremental Reach</apex:outputLabel>
            <apex:actionRegion >
                <apex:inputField value="{!Opp.IncrementalReach__c}" style="color:red;" label="Incremental Reach"/>
            </apex:actionRegion> 
    </apex:pageblockSectionItem>
</apex:pageBlockSection>

with

<apex:pageBlockSectionItem >
     <apex:outputPanel id="op0">
         <apex:outputpanel rendered="{!Opp.PlanContains__c=='OTT/CTV'}">
             <apex:outputLabel style="color:red;font-size:12px;font-weight:750">Incremental Reach</apex:outputLabel>
         </apex:outputPanel>
     </apex:outputPanel>
     <apex:outputPanel id="op11">
         <apex:outputpanel rendered="{!Opp.PlanContains__c=='OTT/CTV'}">
             <apex:actionRegion >
                 <apex:inputField value="{!Opp.IncrementalReach__c}" style="color:red;" label="Incremental Reach"/>
             </apex:actionRegion>
         </apex:outputpanel>
     </apex:outputpanel>
 </apex:pageBlockSectionItem>

As per documentation, <apex:pageBlockSectionItem> components can't be rerendered; rerender the child components instead. So you will have to rerender the components contained in it i.e. in your case op0 and op11. So your below code will be replaced

<apex:actionSupport event="onchange" action="{!null}" rerender="op0"/>

by

<apex:actionSupport event="onchange" action="{!null}" rerender="op0,op11"/>
5
  • I updated with your code snippet, however, the render logic does not appear to be working properly @Vijay Ganji
    – FWSFDC
    May 29, 2019 at 13:30
  • Can you elaborate more on what is not working and in which scenario it's not working, so that I can see if I can help you out on that ? May 29, 2019 at 13:40
  • The render logic now looks to be unresponsive, i.e., when the criteria are met, the checkbox does not appear at all @Vijay Ganji
    – FWSFDC
    May 29, 2019 at 16:18
  • 1
    Yup I got it, it was because PageBlockSectionItem cannot be rerendered, I updated the answer with the updated code, that should work for you. May 30, 2019 at 6:56
  • That worked!! Thank you @Vijay Ganji
    – FWSFDC
    May 30, 2019 at 12:55

You must log in to answer this question.

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