Trying to create Dependent picklist as for some business requirement and salesforce limitation I cannot use standard Dependent picklist provided by salesforce.
I have two picklist fields on my visual force page. Picklist a & Picklist b. Picklist a has values 1,2,3,4 and b has values a,b,c
Now upon selection on picklist a value I want to filter Picklist B . For example if Picklist A has value 1 selected than only display b,c in picklist B
I have achieved this by following code .
My VF Page
<apex:pageBlockSectionItem Id="ype">
<apex:outputLabel value="Type"/>
<apex:actionRegion >
<apex:inputField value="{!opp.Type__c}" id="OppType" >
<apex:actionSupport event="onchange" reRender="Rentinfo" immediate="True" />
</apex:inputField>
</apex:actionRegion>
</apex:pageBlockSectionItem>
<apex:pageBlockSection columns="1" title="Rentinfo" id="RentInfo">
<apex:pageBlockSectionItem >
<apex:outputLabel value="Type" for="OppType"/>
<apex:selectList id="OppType" value="{!opp.Type__c}" size="1" >
<apex:selectOptions value="{!TypeValues}" />
</apex:selectList>
</apex:pageBlockSectionItem>
My Controller
public List<SelectOption> TypeValues {get;set;}
public void setType() {
TypeValues = new List<SelectOption>();
DescribeFieldResult fieldResult = Schema.Opportunity.Type__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
if(opp.L_Type__c == '1') {
TypeValues .add(new SelectOption('B', 'B'));
TypeValues s.add(new SelectOption('C', 'C'));
}
else{
TypeValues.add(new SelectOption('A', 'A'));
TypeValues.add(new SelectOption('B', 'B'));
TypeValues.add(new SelectOption('C', 'C'));
}
}
Above code working absouloutly fine when select Picklist value in Field A and save that after coming back it only show filtered value, However as per requirement it needs same time filtering instead of save and come back.
Can some one please guide me on how to achieve that?