// Controller Class
public class Controller {
public Date ed { get; set; }
public Date sd { get; set; }
public String name { get; set; }
public List<Candidate__c> C {get;set;}
public Controller(){
C= new List<Candidate__c>();
}
public PageReference fetchValues() {
C=[select Name, First_Name__c, Last_Name__c from Candidate__c where (First_Name__c like:name) AND (First_Name__c like:name+'%') AND (First_Name__c like:'%'+name+'%')AND (Start_Date__c>=:sd) AND (End_Date__c<=:ed)];
return null;
}
}
public with sharing class DateRangeCont {
public list<customer__c> customer1 { get; set; }
public datetime startdate1;
public datetime enddate1;
public customer__c a { get; set; }
public DateRangeCont(){
customer1=new list< customer__c>();
a=new customer__c();
}
public PageReference go() {
startdate1=a.From_Date__c;
enddate1=a.To_Date__c;
customer1=[select name,Billing_City__c ,Billing_Postal_Code__c,Createddate from customer__c where Createddate>=:startdate1 AND Createddate<=:enddate1];
return null;
}
}
Please check the below similar sample code that meets your requirement.
<!--------Vf page------->
<apex:page controller="sd_se" sidebar="false"> <apex:form id="dt"> <apex:pageBlock title="Job Details To Search">
<!---search By Date Range--> Start Date<apex:inputField value="{!j.From_date__c}"/> End Date<apex:inputField value="{!j.To_date__c}"/> <apex:commandButton value="Go" action="{!go}" reRender="dt"/>
<!---search By word--> <apex:inputText value="{!keyword}"/> <apex:commandButton value="Search By Word" action="{!getKey_search}"/>
<!---search By Id--> <apex:inputtext value="{!Id}"/> <apex:commandButton value="Search By ID" action="{!getid}"/>
public String Id { get; set; } public List<job__c> jb { get; set; } public String keyword { get; set; }
//Dc public sd_se(){ jb=new List<job__c>(); j=new job__c(); }
public PageReference getid() { jb=[select Name,id,Experience__c,Required_skills__c,Salary__c,From_date__c,To_date__c from job__c where id=:id limit 1]; return null; }
public PageReference getKey_search() { jb=(list<job__c>) [FIND:keyword IN ALL FIELDS RETURNING job__c(Name,id,Experience__c,Required_skills__c,Salary__c,From_date__c,To_date__c)][0]; return null; }
//we need to assign some temp var,for data type public date startdate1; public date enddate1; public PageReference go() { startdate1=j.From_date__c; enddate1=j.To_date__c;
jb=[select Name,id,Experience__c,Required_skills__c,Salary__c,From_date__c,To_date__c from job__c where (From_date__c>=:startdate1) AND (To_date__c<=:enddate1)];
All Answers
Please look into following link where Jeff explained Dynamic queries with example.
http://blog.jeffdouglas.com/2010/07/13/building-a-dynamic-search-page-in-visualforce/
Hope it helps you.
Thanks,
Anjith kumar.
Please check the below similar sample code that meets your requirement.
Hope this helps you!
Best Regards,
Deepthi
Please check the below sample code.
VisualForce Page:
Controller:
Hope this helps you!
Best Regards,
Jyothsna
Please check the below similar sample code that meets your requirement.
<!--------Vf page------->
<apex:page controller="sd_se" sidebar="false">
<apex:form id="dt">
<apex:pageBlock title="Job Details To Search">
<!---search By Date Range-->
Start Date<apex:inputField value="{!j.From_date__c}"/>
End Date<apex:inputField value="{!j.To_date__c}"/>
<apex:commandButton value="Go" action="{!go}" reRender="dt"/>
<!---search By word-->
<apex:inputText value="{!keyword}"/>
<apex:commandButton value="Search By Word" action="{!getKey_search}"/>
<!---search By Id-->
<apex:inputtext value="{!Id}"/>
<apex:commandButton value="Search By ID" action="{!getid}"/>
<!---which fiels we want to display -->
<apex:pageBlockSection columns="1">
<apex:pageBlockTable var="jj" value="{!jb}">
<apex:column headerValue="Name" value="{!jj.Name}"/>
<apex:column headerValue="Experience" value="{!jj.Experience__c}"/>
<apex:column headerValue="Required skills" value="{!jj.Required_skills__c}"/>
<apex:column headerValue="salary" value="{!jj.salary__c}"/>
<apex:column headerValue="Record Id" value="{!jj.id}"/>
<apex:column headerValue="Start Date" value="{!jj.From_date__c}"/>
<apex:column headerValue="End Date" value="{!jj.To_date__c}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class sd_se {
public job__c j { get; set; }
public String Id { get; set; }
public List<job__c> jb { get; set; }
public String keyword { get; set; }
//Dc
public sd_se(){
jb=new List<job__c>();
j=new job__c();
}
public PageReference getid() {
jb=[select Name,id,Experience__c,Required_skills__c,Salary__c,From_date__c,To_date__c from job__c where id=:id limit 1];
return null;
}
public PageReference getKey_search() {
jb=(list<job__c>) [FIND:keyword IN ALL FIELDS RETURNING job__c(Name,id,Experience__c,Required_skills__c,Salary__c,From_date__c,To_date__c)][0];
return null;
}
//we need to assign some temp var,for data type
public date startdate1;
public date enddate1;
public PageReference go() {
startdate1=j.From_date__c;
enddate1=j.To_date__c;
jb=[select Name,id,Experience__c,Required_skills__c,Salary__c,From_date__c,To_date__c from job__c where (From_date__c>=:startdate1) AND (To_date__c<=:enddate1)];
return null;
}
}
Hope this helps you!
Best Regards,
BNB