I have an Object, lets say 'Resources' Each object have type, lets say 'Contractors' Each 'Contractor' may have sub-types A, B, C, D
I have visualforce page setup that outputs all 'Contractors' as a table, but I also want to have Sub-types dropdown with A, B, C, D values with option to filter Contractors (Lets say, I select 'A', page will be refreshed, and all contractors with sub-type A appear).
Type and Sub-type are related list (Type is controlling field for sub-type)
I would really appreciate for your help.
Thank you.
I had sort of the same problem and this is how I developed it.
your Visual force page:
<apex:outputPanel id="PanelId">
<apex:selectList size="1" id="firstList" value="{!firstListVauleId}">
<apex:actionSupport event="onchange" action="{!UpdateSelectedFirstItem}" reRender="PanelId"/>
<apex:selectOptions value="{!FirstListOptions}" />
</apex:selectList>
<apex:selectList size="1" id="secondList" value="{!secondValueId}">
<apex:selectOptions value="{!SecondListOptions}" />
</apex:selectList>
</apex:outputPanel>
your apex class:
public String firstListVauleId {get;set;}
public String secondListVauleId {get;set;}
public List<SelectOption> getfirstListOptions()
{
List<SelectOption> options = new List<SelectOption>();
// add items add needed. you can make database queries.
return options;
}
public List<SelectOption> getsecondListOptions()
{
List<SelectOption> options = new List<SelectOption>();
// add options based on the first list selection. you can make database queries.
return options;
}
public void UpdateSelectedFirstItem()
{
// do your stuff if you need to do anything upon changing the first dropdown selected item.
}