function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
kcpluspluskcplusplus 

rerender based on picklist value

I have three charts created as formulas and I wanted to conditionally display them based on a selected picklist value. I read a few posts on how to do this and it seemed really simple. I used an action support and an on change event, but the output Panel is not rerendering.

 

<apex:Form >
   <apex:actionRegion >
        <apex:inputField value="{!Quote.Chart__c}">
             <apex:actionSupport event="onChange" reRender="Panel"/>
        </apex:inputField>
   </apex:actionRegion>
</apex:Form>
        
<apex:outputPanel id="Panel">
    <apex:outputText value="{!IF(Quote.Chart__c ="Quantity",Quote.QuantityChart__c,"")}" escape="false"  label=""/>
</apex:outputPanel>

 

I seem to remember that I had issues displaying an image formula in a merge formula before, but I can't remember if it isn't possible. I select a picklist value but the chart does not display. Right now I'm using an if merge formula to test, but I was going to move it to a case for each picklist choice once I had it working. 

 

Am I doing this the right way, or do I need to go about it a different way?

S91084S91084

Change the event="onChange" to event="onchange" in your visualforce page code

kcpluspluskcplusplus

I just tried that, it didn't change it. I did move the logic for the image that should display into the image formula. So I'm not using a conditional merge formula anymore. The issue is that when I select a picklist value, the chart is not displaying. 

 

--KC

S91084S91084

The following code works for me:

 

<apex:page standardController="Account">
    <apex:form>
        <apex:inputField value="{!Account.Type}">
            <apex:actionSupport event="onchange" reRender="panel"/>
        </apex:inputField>
        <apex:outputPanel id="panel">
            {!Account.Type}
        </apex:outputPanel>
    </apex:form>
</apex:page>

Even after this your code doesn't work, please post the whole code to check for any dependencies

 

kcpluspluskcplusplus

That works, except as soon as I try to use my formula field returning the image, it stops working. It actually pushed out the HTML code that gets created from the visualforce, which I assume means having a formula push through this way is just not supported. 

 

I tried using the {!save} action on the actionsupport, to commit the picklist value when it's changed, and it works to rerender the chart but then it loads the whole page into the section on the Quote page I have the vf page in, since I can't override the quote detail page. Is there a way to only rerender the section that the page is in, or do I need to go about conditionally displaying this a different way?

S91084S91084

make you Save method's return type  void if you are using PageReference and rerender the panels required after saving.

kcpluspluskcplusplus

I'm using the standard controller though and the standard save action, do I need to use a custom controller to do this then?

 

--KC

S91084S91084

You will have to use the custom save action, as you cannot control the redirection with the standard save. When you hit save (standard) it takes you to the detail page.

kcpluspluskcplusplus

I have to plead a little ignorance here on custom controllers, I'm good with apex but I haven't really gotten into using it with visualforce. 

 

I get the idea of what I need to do, would you happen to have a link to something I can reference on how to do this or a link to an example?

 

Thanks so much for your help, I think this is the answer :]

 

--KC