You need to sign in to do that
Don't have an account?
Jina Chetia
How to make dependent picklist work in VisualForce page?
Hi,
I have a Contract Terms Custom Object which has a dependent picklist named 'Territory' depending on 'Region' picklist. I have used these two picklist in my page using the inputField tag but I am not getting the behaviour of the depending picklist. As soon as I change the Region value, the Territory picklist values should change depending on the value selected but it does not happen.
Here is the piece of code
Can anyone please help me resolve this issue?
Thanks,
Jina
I have a Contract Terms Custom Object which has a dependent picklist named 'Territory' depending on 'Region' picklist. I have used these two picklist in my page using the inputField tag but I am not getting the behaviour of the depending picklist. As soon as I change the Region value, the Territory picklist values should change depending on the value selected but it does not happen.
Here is the piece of code
Code:
<apex:pageBlock title="Section 2" rendered="{!showSecondSection}"> <p>To what geography does this rate apply— </p> Region: <span style="padding:10px;"/> <apex:inputField value="{!contractTerms.REGION__c}"></apex:inputField> <p> Territory: <span style="padding:10px;"/> <apex:inputField id="territory" value="{!contractTerms.TERRITORY__c}"/></p> <p><span style="padding:10px;"/><apex:commandButton action="{!showSection3}"
value="Continue" styleClass="btn"></apex:commandButton></p><br/> </apex:pageBlock>
Thanks,
Jina
Until then, if you want the dependency logic I think you'll have to build it yourself by using events (onBlur etc.) on inputfield in tandom with components like apex : actionSupport
I create 2 custom picklist field (A and B), B's value depends on A.
I wrot ajax and apex to set B's value when A changes. In sf I set B as {1,2,3} when A is 1. set B {2,3,4} when A is 2.
But I can not find the apex api to select dependency relation between A and B. I want to write code like below.
Select values from B where B.dependencyvalue = A.value.
do you know how to select the dependency relation between A and B?
do you know how to select the dependency relation between A and B with Apex code?
my post it as below:
http://community.salesforce.com/sforce/board/message?board.id=Visualforce&thread.id=7138
most of us are not looking for a javascript solution, but rather an Apex solution, run on platform, and completely compliant with on platform dependencies.
is there a way to access this information in Apex or not?
furthermore, what is the point of the isDependentPicklist() method of Field Describe Result if you really can't do anything but confim, yes, this is a dependent picklist.
The solution here is to extend getPicklistValues() to accept a param, which is the selected value of the controlling field. Are you listening Salesforce?
I was able to successfully implement Richard's solution, however when i hit save I receive a validation error message "Value is not valid"
I get this error on the dependentField!
Any idea why?
Sam, were you able to Resolve your error? I'm facing the same error.
OMG... you have to be kidding me... :(
This is horribly frustrating.
I got Richard's code to work properly (after fighting the "Value is not valid" validation errors). The dependent pick lists must be populated from a VisualForce controller first. See my solution here:
http://brandticeincoderland.blogspot.com/2010/01/fun-with-dependent-picklists-in.html
As a side note, please vote up this idea on idea exchange, so we don't have to implement silly workarounds:
http://sites.force.com/ideaexchange/ideaView?c=09a30000000D9xt&id=08730000000BrogAAC&returnUrl=%2Fapex%2FideaList%3Fc%3D09a30000000D9xt%26category%3DApex%2B%2526%2BVisualforce%250D
Message Edited by babbott on 02-05-2010 05:58 PM
Have you guys looked at this article:
http://wiki.developerforce.com/index.php/Extended_Functionality_of_Visualforce_-_Part_1
It looks pretty straightforward, a VF controller and an <actionSupport> tag.
Rich C.
Hi Babbott,
I have read ur blog and followed ur steps. but it doesnt work.
I am not sure what the last parameter -- initialValues should be for function DependentPicklistHelper().
Could you give me an example?
Can it be set to ''?
Many thanks,
Thomas
In case anyone else stumbles across this thread, pretty sure VF now supports this:
http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_dependent_picklists.htm
It is still not working properly. If the value of the controlling field is changed in the controller, the dependent picklist is not trimmed down to specific values, but is displaying all of the values available.
This is the case when the VF page is only displaying the dependent picklist, and is not displaying the controlling field. If both fields are displayed on the page, then the dependency is working correctly.
That is true, both controlling and dependent fields need to be in page then it works ok.
Workaround to have only the dependent field shown is to modify the page DOM with own javascript.