+ Start a Discussion
Gheorghe Sima 25Gheorghe Sima 25 

Multiselect picklist component in visualforce

Hi,
I have 2 multiselect picklist component in a visualforce page and when the user modifies the first multiselect picklist I want to change the value from the second multiselect picklist. I want to make a dependency between those 2 picklist multiselect, but my code doesn't work...

Here is my code:
<apex:page standardStylesheets="true" controller="NewAccountAPVController2"  tabStyle="Account">
  <apex:param id="accountID" name="accountID" value=""/>
  <apex:pageMessages />
  <apex:form >
      <script type="text/javascript">  
          function navigate(){ 
              searchServer();  
          }
      </script>
      <apex:actionFunction name="searchServer" action="{!RefreshMultiSelect}" rerender="results"> </apex:actionFunction>
      <apex:pageBlock title="New Account">
          <apex:pageBlockButtons >
              <apex:commandButton action="{!cancel}" value="Cancel" styleClass="btn"/>
              <apex:commandButton action="{!savePage21}" value="Save" styleClass="btn"/>
          </apex:pageBlockButtons>
          <apex:pageBlockSection title="Subcategorie" columns="1">
              <c:MultiselectPicklist leftLabel="Subcategorii" 
                leftOptions="{!subcategory}"
                rightLabel="Subcategorii selectate"
                rightOptions="{!selectedSubcategory}"
                size="15"
                width="300px" onchange="navigate();"
              />
           </apex:pageBlockSection>
         <apex:pageBlockSection title="Subsubcategorie">
            <c:MultiselectPicklist leftLabel="Subsubcategorii" 
                 leftOptions="{!subsubcategory}"
                 rightLabel="Subsubcategorii selectate"
                 rightOptions="{!selectedSubSubCategory}"
                 size="15"
                 width="300px"
                 id="results"
            />  
        </apex:pageBlockSection>
      </apex:pageBlock>
  </apex:form>
</apex:page>

Can anyone help me? 
Swetha Sfdc1Swetha Sfdc1
Hi Gheorghe Sima 25,

There are 2 ways to acheive dependent picklist
1-> Controller
2-> Adding Dependent Fields

Sample example:
<apex:page controller="positionController">
    <apex:form >
                    <apex:inputfield value="{!position.Functional_Area__c}">
                     </apex:inputfield>
                    <apex:inputfield value="{!position.Job_Level__c}">
                    </apex:inputfield>
    </apex:form>
</apex:page>
public class positionController {
    public Position__c position { get; set; }
    public positionController()
    {
        position = [Select ID, Functional_Area__c, Job_Level__c From Position__c limit 1];
    }
}
Another Way :

http://www.infallibletechie.com/2012/10/dependent-picklist-using-apex-in.html

Adding Dependent Fields

https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_quick_start_dependent_picklists.htm

Thanks
Swetha
NarutoNaruto
@Gheorghe Sima 25

Did you got solution for this. How to use onchange attribute in c:MultiselectPicklist component?