0

I have an actionSupport with actionReqion on pageBlockTable which is not rendering properly but it renders perfectly on pageBlockSectionItem.

        <apex:pageblocktable>
             <apex:column style="width:50px" rendered="{!vehicleOrder}">
                  <apex:facet name="header">
                    <apex:outputLabel value="Car" for="selectedcar"/>
                  </apex:facet> 
                       <apex:actionRegion >
                        <apex:selectList value="{!vw.Item.Car__c}" size="1" id="selectedcar">  
                          <apex:actionSupport event="onChange"  rerender="models" immediate="true"/>
                            <apex:selectOptions value="{!vw.carOptions}">
                           </apex:selectOptions>
                        </apex:selectList>
                      </apex:actionRegion>
                </apex:column>
                <apex:column style="width:50px" rendered="{!vehicleOrder}">
                   <apex:facet name="header">
                     <apex:outputLabel value="Model" for="models"/>
                   </apex:facet>            
                    <apex:actionRegion >
                     <apex:selectList value="{!vw.Item.Model__c}" size="1" id="models" disabled="{!ISNULL(selectedcar)}"> 
                        <apex:selectOptions value="{!vw.modelOptions}"></apex:selectOptions>
                     </apex:selectList> 
                   </apex:actionRegion> 
                </apex:column> 
          </apex:pageblocktable>
5
  • in what context? lex, classic? what part is not rendering (the whole pageblocktable)? any errors?
    – glls
    Jul 17, 2018 at 17:45
  • Its classic, on "Car" selection the "Model" list should render. There are no specific errors just the rendering of model list column is not working Jul 17, 2018 at 17:48
  • I believe this has to do with how Visualforce resolves component Ids. If you give the whole <apex:pageBlockTable> an Id and rerender it, does that work?
    – David Reed
    Jul 17, 2018 at 18:03
  • Are you hoping that in a given row of your table, the select options will change just in that row based on the items selected in an adjacent column?
    – pchittum
    Jul 18, 2018 at 8:04
  • Yes, the models should change based on car selection on same row Jul 18, 2018 at 14:13

1 Answer 1

2

There are two things you may need to address. (And let me confess, this is completely from memory for how this feature works!)

From what I can tell the conditional (with the rendered attribute) for that block of markup is the column, but you're only rerendering a node that is inside that column, which is a non-rendered node.

     this part is not rendered--------------V
                                            V
<apex:column style="width:50px" rendered="{!vehicleOrder}">
   <apex:facet name="header">

but this is what you're rerendering---------V
                                            V
     <apex:outputLabel value="Model" for="models"/>
   </apex:facet>            
    <apex:actionRegion >
     <apex:selectList value="{!vw.Item.Model__c}" size="1" id="models" disabled="{!ISNULL(selectedcar)}"> 
        <apex:selectOptions value="{!vw.modelOptions}"></apex:selectOptions>
     </apex:selectList> 
   </apex:actionRegion> 
</apex:column> 

Rerendering something that isn't rendered in the first place will always fail. Even attempting to rerender the node directly, your apex:outputLabel in this example, will fail. You always need to rerender something one level or more higher than the thing you want to make appear/disappear. In this instance, it looks like that should be your apex:pageBlockTable element.

The other thing that is likely impeding progress is immediate="true" in your apex:actionSupport tag.

<apex:actionSupport event="onChange" rerender="models" immediate="true"/>

By setting this, you will not post back any data from your current page state. Presumably you'd need to do that to toggle the vehicleOrder property and thus make the column appear when your table rerenders.

1
  • Removed the rendered attribute on column and tried to render the entire pageblock table but still the rendering is not happening Jul 17, 2018 at 18:54

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.