I want to hide the selected value from picklist so that in next picklist that value shouldn't appear. I have a grid in which I have 5 picklist so If I have selected 1st value in picklist that value should disappear from second picklist and it goes on and on

Controller :

public class mapClass 
public List<WrapperClass> wrapList{get;set;}
public String name{get;set;}
public String field{get;set;}

public mapClass()
    wrapList = new List<WrapperClass>{new WrapperClass('',''),new WrapperClass('',''),new WrapperClass('',''),new WrapperClass('',''),new WrapperClass('','')};        

public class WrapperClass
    public string name{get;set;}
    public string field{get;set;}
    public WrapperClass(string name, string field)
        this.name = name;
        this.field = field;

public list<WrapperClass> getWrapRecords()
     WrapperClass wrapObj = new WrapperClass(name, field);
     return wrapList ;

public List<SelectOption> getObjectFields()
    List<SelectOption> objFieldOption = new  List<SelectOption>();
    Schema.DescribeSObjectResult obj = Schema.getGlobalDescribe().get('Account').getDescribe();
    Map<String, Schema.SObjectField> fieldMap = obj.fields.getMap();
    for(Schema.SObjectField fieldObj :  fieldMap.Values())
        Schema.DescribeFieldResult fieldDesc = fieldObj.getDescribe();
        objFieldOption.add(new SelectOption(fieldDesc.getname(),fieldDesc.getname()));
    return objFieldOption;

Vf Page :

<apex:page controller="mapClass">
<apex:form >
  <apex:pageblock >
      <apex:actionRegion >
      <apex:outputPanel id="fields">
          <apex:pageblocktable value="{!wrapList}" var="r">
             <apex:column headervalue="Name">
                <apex:inputText value="{!r.Name}"/>

                 <apex:column headervalue="Fields">
                     <apex:selectList value="{!r.field}" size="1" >
                         <apex:selectOptions value="{!ObjectFields}" />
                         <apex:actionSupport event="onchange" reRender="fields"/>


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.