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
VarunCVarunC 

Dependent Picklist in visualforce pages

I've 2 picklists, A & B, B picklist has A set as Controlling fields, now these two fields are not behing as dependent fields in my VF page :(. I wasn to display B values based on the selection on A picklist.

 

The dependent Picklists have been Set appropriately in Object. But when I use them in VF page the values just do not change, bit the picklists show All values stored in the field, irrespective of the selected value in the controlling field.

 

Can anyone help me here .. plz .... :(

JimRaeJimRae
Unfortunately, dependent picklists are not supported in VF pages.  You will need to use a custom controller or extension and programatically make the dependencies.
VarunCVarunC
Ok, you mean to hard code values in the dropdown using custom extensions methods ?
JimRaeJimRae

I haven't tryed to do it yet, but my plan is that I would create a map of the dependent values to their related list, then every time something is selected in the controlling list,  I would update the dependent list with the new subset.  Not elegant, or easy to maintain, but all I can think of to address this need.

Maybe you  could post your code if you get something working?

VarunCVarunC

My issue with coding is that, i am not able to read the Controlling field's value, I mean,

 

List A         List B

Val 1           B Val 1

                  B Val 2

Val 2           B Val 3

                  B Val 4

                  B Val 5

 

No in above example, my issue is I can read values in both the picklists, but HOW CAN i get the List B's values on the basis of selection in List A's value? I could not achieve that, so I'm stuck :(

JimRaeJimRae

Just did a quick google search and found this article,

Might help us both:

 

http://wiki.apexdevnet.com/index.php/Extended_Functionality_of_Visualforce_-_Part_1

 

 

VarunCVarunC

Yes already tried that, but if you havn't noticed then on PAGE 2 of this article its code uses 2 DIFFERENT objects to populate the 2 different Dropdown, so its simply a population of values using a QUERY which ran on 2 objects having picklist fields, but not on ONE object with 2 picklist fields with Controlling field set for one of them :(

JimRaeJimRae
My suggestion was to adapt that concepts in that article to your needs.
VarunCVarunC
yes exactly, I have tried to use his concept .... I tried workign on it applying actionRegion tags, and tried refreshing the picklists, but the Dependent Picklist DIDn't populated with Selected Controlling field's value ...
glorgeglorge

I'm facing this issue now as well...

 

Have you tried going down the metadata API route yet?

 

http://blog.sforce.com/sforce/2008/12/using-the-metadata-api-to-retrieve-picklist-values.html

 

-Greg

VarunCVarunC
yup .. already tried API coding tricks ... but no luck .. :(