• T L TEJASWINI
  • NEWBIE
  • 10 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
My code is at present hard coded
vf page
======
<apex:page controller="EmployeeDataClass">
 <apex:form >
 <apex:pageBlock title="Department:" >
 <apex:outputText value="{!selectedEmp}" label="you have selected:"/>
  <apex:pageBlockSection title="Custom Picklist Using selectList and selectOptions departments" collapsible="false">
  <apex:selectList value="{!selectedEmp}" multiselect="false" size="1">
                <apex:selectOptions value="{!countriesOptions}"/>
                </apex:selectList>
  </apex:pageBlockSection>              
     <apex:pageBlock title="Employee Data">
         <apex:pageBlockTable value="{!lstEmp}" var="e">
             <apex:column headerValue="Employee Name" >
                 <apex:outputtext value="{!e.Name}"></apex:outputtext>
             </apex:column>
             <apex:column headerValue="Employee City" >
                 <apex:outputtext value="{!e.Email__c}"></apex:outputtext>
             </apex:column>
             <apex:column headerValue="Employee Contact" >
                 <apex:outputtext value="{!e.Phone__c}"></apex:outputtext>
             </apex:column>
              <apex:column headerValue="Employee department" >
                 <apex:outputtext value="{!e.Dept__c}"></apex:outputtext>
             </apex:column>
         </apex:pageBlockTable>
     </apex:pageBlock>
     </apex:pageBlock>
 </apex:form>
</apex:page>

controller
========
public class EmployeeDataClass{

   /*
       constructor is a method which executes automatically when the class is loaded.
       
   */
   public List<Employee__c> lstEmp{get;set;} // Property Declaration.
   public String selectedEmp{get;set;}

   public EmployeeDataClass(){
       lstEmp = new List<Employee__c>(); // Initialization.
       
       lstEmp = [select id,name,email__c,phone__c,dept__c from Employee__c  limit 50000];
         
   }
    public List<SelectOption> getCountriesOptions() {
        List<SelectOption> countryOptions = new List<SelectOption>();
        countryOptions.add(new SelectOption('','-None-'));
        countryOptions.add(new SelectOption('Learning','Learning'));
        countryOptions.add(new SelectOption('HR','HR'));
        countryOptions.add(new SelectOption('Accounts and Finance','Accounts and Finance'));
        countryOptions.add(new SelectOption('Infrastructures','Infrastructures'));
        countryOptions.add(new SelectOption('Research and development','Research and development'));
        countryOptions.add(new SelectOption('Product development','Product development'));
        countryOptions.add(new SelectOption('IT services','IT services'));
        
        return countryOptions;
    }
    public PageReference save(){
        return null;
    }
}

===================
Now I want code in controller to be dynamic.Please suggest any ideas.