You need to sign in to do that
Don't have an account?
maha123
Rendered problem with multi value picklist
Hello
I hope that someone can help me with my code
first, I have a vf page. In this page, there are sections that supposed to be hidden/shown according to the value of a multi-picklist. The standardController "Client Session Record" is a custome object
<apex:page standardController="Client_Session_Record__c"> <apex:sectionHeader title="New client Session Record" subtitle="{!Client_Session_Record__c.name}"/> <apex:form > <apex:pageBlock title="Client Session Record Edit" id="thePageBlock" mode="edit"> <apex:pageMessages /> <!--the buttons block --> <apex:pageBlockButtons > <apex:commandButton value="Save" action="{!save}"/> <apex:commandButton value="Cancel" action="{!cancel}"/> </apex:pageBlockButtons> <!--end of buttons block --> <apex:actionRegion > <!--Section 1 --> <apex:pageBlockSection title="Information" columns="2"> <apex:inputField value="{!Client_Session_Record__c.name}"/> <apex:pageBlockSection > <apex:pageBlockSectionItem > </apex:pageBlockSectionItem> <!-- empty selectItem--> <apex:pageBlockSectionItem /> </apex:pageBlockSection> <apex:inputField value="{!Client_Session_Record__c.Date_of_visit__c}"/> <apex:inputField value="{!Client_Session_Record__c.Advisor__c}"/> <apex:inputField value="{!Client_Session_Record__c.Client__c}"/> <apex:inputField value="{!Client_Session_Record__c.X2nd_Advisor__c}"/> <!-- the condition --> <apex:pageBlockSectionItem > <apex:outputLabel value="Session Type"/> <apex:outputPanel > <apex:inputField value="{!Client_Session_Record__c.Session_Type__c}"> <apex:actionSupport event="onchange" reRender="Section2, Section4" immediate="true" status="status"/> </apex:inputField> <apex:actionStatus startText="Updating the value..." id="status"/> </apex:outputPanel> </apex:pageBlockSectionItem> <!-- end of condition --> <apex:inputField value="{!Client_Session_Record__c.Next_Review_Date__c}"/> <apex:inputField value="{!Client_Session_Record__c.Location__c}"/> </apex:pageBlockSection> <!--Section 1 --> </apex:actionRegion> <!--Section 2 --> <apex:pageBlockSection title="Initial" id="Section2" columns="2" collapsible="true" Rendered="{!if(Client_Session_Record__c.Session_Type__c=='Initial Assessment',true,false) }" > <apex:inputField value="{!Client_Session_Record__c.Recommended_AT__c}" required="true" /> </apex:pageBlockSection> <!--Section 2 --> </apex:pageBlock> </apex:form> </apex:page>
My problem is that , it didn't work!
Multi-select picklists can be used only with a limited set of formula functions & that's the reason your rendered formula didn't work. So, the only way is to set this Boolean value using a controller or extension class.
Below is the working sample code:
PAGE:
EXTENSION:
I think the CONTAINS function can help u . Here Location is the multiselect on the basis of which i am rendering the "nameSection"
Thanks SwatKat, i tried this before and it didn't work
Karthikeyan i tried your ext class but still the sections are not showing when I want them to
Hope you can tell me more or what I'm missing
here is my vf page
and the class
You have missed to call the checkValue action method whenever the SessionType field changes.
So, just add action={!checkValue} to the sessiontype inputfield, as shown below & it'll work as you expect.
Also, just noted one more mistake:
Replace the Client_Session_Record__c variable ONLY in your VF page with clientSession
I really appreciate your help for now that I got a result, thanks to u.
But still works funny! :(
It only works after saving the record and doesn't hide/show what I want when I do select from the picklist.
also I had to reselect "initial assessment" from the picklist with the saved records to show the hidden fields
even after I save it, i still need to reselect my choices next time i try to edit
I guess, only other culprit is the actionRegion part.
Currently actionRegion encloses the whole section1, so change it just enclose the inputfield:Session_Type__c.
This should enable partial refresh without saving the record.
I changed the actionRegion to encloses only the "Session_Type__c" field.
yet still it doesn't work properly!
1. If I create any new record and try to choose "Initial Assessment", nothing happens as if the event=onchange doesnot work!
2. If I try to modify a record, and "Initial Assessment" is already selected, the rendered fields still doesn't show until I reselect "Initial Assessment"; event=onchange must be forced although it's already in selected choices
Thanks again
In the case above that would be:
SwatKat almost had it above. His suggestion was: !if(contains(SObject.multipicklistfield__c,"value"),false,true) The problem was the quotation mark instead of apostrophe. His solution works fine outside of a visualforce page, but in the Visualforce notation the quotation marks around the value cause a format error because Visualforce thinks that they are the end of the rendered statement.
BUT border effects are
- i need to add my outputField into an outputPanel
- i need to do a trick to show the Label + having the good format for the label <- a real nightmare !
Here is the code i am using, which is aroung 98% of what i want (tehre is a little left margin)