+ Start a Discussion
Nagaraju Mogili 31Nagaraju Mogili 31 

I want to filter the records from a list of contacts, I have attached my vf page. when I enter the firstname, the related names only displayed in the below section.

User-added image

Here is Mycode:  Apex controller ===========

public class records {
    public Schema.contact con {get;set;}
    public list<Schema.contact> conlist {get;set;}
    public String regionValue {get;set;}   
    public List<SelectOption> regionOptions {get;set;}
    public List<Schema.contact> filteredcontacts {get;set;}

    private integer totalRecs = 0;     
    private integer index = 0;
    private integer blockSize = 10;
   public records(){
           totalRecs = [select count() from contact];
    public records(ApexPages.StandardController controller) {
          regionOptions = new List<SelectOption>();
          regionOptions.add(new SelectOption('Web','Web'));
          regionOptions.add(new SelectOption('Phone Inquiry','Phone Inquiry'));
          regionOptions.add(new SelectOption('Partner Referral','Partner Referral'));
          regionOptions.add(new SelectOption('Purchased List','Purchased List'));
          regionOptions.add(new SelectOption('Other','Other'));
      public void updatefilteredcontacts(){
         filteredcontacts = [select firstname,LastName from contact where contact.Leadsource =: regionValue];
    public list<Schema.contact> getcontacts(){
      list<Schema.contact> conlist = new list<Schema.contact>();
       conlist =[select firstname,lastName,LeadSource from contact   LIMIT:blockSize OFFSET :index];
      return conlist;
    public void beginning(){    
        index = 0;
     public void previous(){
        index = index - blockSize;

   public void next(){
        index = index + blockSize;

    public void end(){
        index = totalrecs - math.mod(totalRecs,blockSize);
      public boolean getprev(){
        if(index == 0)
        return true;
        return false;
      public boolean getnxt(){    
        if((index + blockSize) > totalRecs)
        return true;
        return false;

=============== VF Page ================================

<apex:page controller="records">
   <apex:form >
          <!--<apex:selectList value="{!regionValue}" size="1"> 
             <apex:selectOptions value="{!regionOptions}"/>
         <apex:commandButton value="Update Contacts" action="{!updatefilteredcontacts}"/>-->

           <apex:pageBlock >
             <apex:pageBlockSection title="Filters">
                 <apex:inputText value="{!con.FirstName}" label="FirstName"/>
                 <apex:inputText value="{!con.LastName}" label="Last Name"/>
                 <apex:inputField value="{!con.Leadsource}" />
     <apex:pageBlock id="details">
         <apex:pageblockButtons >      
          <apex:panelGrid columns="4">
            <apex:commandButton value="Begining" rerender="details" action="{!beginning}" disabled="{!prev}"/>
            <apex:commandButton value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/>
            <apex:commandButton value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/>
            <apex:commandButton value="Ending" rerender="details" action="{!end}" disabled="{!nxt}"/>                                    
          <apex:pageBlockTable value="{!contacts}" var="x">
              <apex:column value="{!x.FirstName}"/>
              <apex:column value="{!x.lastName}"/>
              <apex:column value="{!x.LeadSource}"/>
       <apex:pageBlock >
       <apex:pageBlockSection title="Displaying the contacts based on Search">
           <apex:pageBlockTable value="{!filteredcontacts}" var="contac">
              <apex:column value="{!contac.firstName}"/>
    <apex:slds />
Nagaraju Mogili 31Nagaraju Mogili 31
I want to search the results from three fileds, those are firstname,Lastname,Leadsource