You need to sign in to do that
Don't have an account?
Michael Hedrick 2
Dependency Picklist Value Issues on VF Page
Hello,
I am having a couple issue on my VF page in regard to rendering Dependant Picklist Value,
The main picklist filed is fine. But once a value is select the dependant picklist field(Category) are not correct.
Either it does not show or it is duplicated multiple time.
Also, the Last picklist field SubCategory is not populating any values at all and I am not sure if its the VF or Apex Code.
Any help is appreciated,
M
Controller:
Visualforce Page
I am having a couple issue on my VF page in regard to rendering Dependant Picklist Value,
The main picklist filed is fine. But once a value is select the dependant picklist field(Category) are not correct.
Either it does not show or it is duplicated multiple time.
Also, the Last picklist field SubCategory is not populating any values at all and I am not sure if its the VF or Apex Code.
Any help is appreciated,
M
Controller:
public class MerchandisingController { public string Merchandise{ get; set; } public string Category{ get; set; } public string SubCategory { get; set; } public MerchandisingController (ApexPages.StandardController controller) { Merchandise= Category= SubCategory = null; } public List<SelectOption> getListMerch() { List<SelectOption> options = new List<SelectOption> { new SelectOption('','-- Choose Merchandise --') }; for(Schema.PicklistEntry pe:Merchandising__c.Merchandise__c.getDescribe().getPicklistValues()) { options.add(new SelectOption(pe.getValue(),pe.getLabel())); } return options; } public List<SelectOption> getListCategory() { List<SelectOption> options = new List<SelectOption>(); if(Merchandise == null || Merchandise == '') return options; options.add(new SelectOption('','-- Choose Category --')); for(Merchandising__c cat:[select id,Merchandise_Category__c from Merchandising__c where Merchandise__c= :Merchandise]) { options.add(new SelectOption(cat.id,cat.Merchandise_Category__c )); } return options; } public List<SelectOption> getListSubCategory() { List<SelectOption> options = new List<SelectOption>(); if(Category==null || Category== '') return options; options.add(new SelectOption('','-- Choose SubCategory --')); for(Merchandising__c sub:[select id,Merchandise_SubCategory__c from Merchandising__c where Merchandise_Category__c = :Category]) { options.add(new SelectOption(sub.id,sub.Merchandise_SubCategory__c)); } return options; } }
Visualforce Page
<apex:page standardController="Merchandising__c" extensions="MerchandisingController"> <apex:form id="Merchandising"> <apex:sectionHeader title="Choose Merchandizing"/> <apex:pageBlock title="Demo Page"> <apex:pageBlockSection columns="1"> <apex:pageBlockSectionItem > <apex:outputLabel >Merchandise</apex:outputLabel> <apex:selectList size="1" multiselect="false" value="{!Merchandise}"> <apex:selectOptions value="{!ListMerch}"/> <apex:actionSupport reRender="Merchandising" event="onchange"/> </apex:selectList> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >Category</apex:outputLabel> <apex:selectList value="{!Category}" size="1" multiselect="false"> <apex:selectOptions value="{!ListCategory}"/> <apex:actionSupport reRender="Merchandising" event="onchange"/> </apex:selectList> </apex:pageBlockSectionItem> <apex:pageBlockSectionItem > <apex:outputLabel >SubCategory</apex:outputLabel> <apex:selectList value="{!SubCategory}" size="1" multiselect="false"> <apex:selectOptions value="{!ListSubCategory}"/> <apex:actionSupport reRender="Merchandising" event="onchange"/> </apex:selectList> </apex:pageBlockSectionItem> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
May be I am missing something, but the fields Merchandise__c, Merchandise_Category__c, Merchandise_SubCategory__c all are custom fields in the Merchandising__c object, you can just display them using standardController. Is there any other logic in your extension ?
All Answers
May be I am missing something, but the fields Merchandise__c, Merchandise_Category__c, Merchandise_SubCategory__c all are custom fields in the Merchandising__c object, you can just display them using standardController. Is there any other logic in your extension ?
Thank you for the reply. I need to be able to assign the VF page to a button on the Account object. Does using apex:inputField component still allow for picklist with dependancies?
Thanks,
M
Cheers,
M
Now just need to come up with save and cancel funtionality.
Thanks,
M