I dont understand what you are trying to say. If you want only the search text box and no buttons, you can use the "onkeyup" or something else in the <apex:inputText> tag. For eg. :
VF Page:
<apex:page controller="contactActivityHistory3">
<apex:form >
<apex:pageBlock title="Filter">
<!-- <apex:pageBlockButtons >
<apex:commandButton value="Fetch" action="{!fetch}" reRender="pagination"/>
</apex:pageBlockButtons> -->
<apex:pageBlockSection >
<apex:inputText value="{!status}" label="Status" onkeyup="{!Fetch}"/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Activity History" id="pagination">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!ListTasks}" var="tsk">
<apex:column headerValue="Contact" value="{!tsk.WhoId}"/>
<apex:column headerValue="Subject" value="{!tsk.Subject}" />
<apex:column headerValue="Status" value="{!tsk.Status}"/>
<apex:column headerValue="Modified Date" value="{!tsk.LastModifiedDate}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Controler:
public class contactActivityHistory3 {
public Boolean fetchCalled{get;set;}
public String taskList{get;set;}
public String status{get;set;}
public String subject{get;set;}
public contactActivityHistory3() {
fetchCalled = false;
}
public void getFetch() {
taskList = 'SELECT WHOID, Subject, Status, LastModifiedDate FROM Task WHERE Status LIKE \'%'+status+'%\'';
List<Task> tskList = Database.query(taskList);
fetchCalled = true;
}
public Task[] getListTasks() {
List<Contact> cntct = [SELECT Id, Name FROM Contact];
List<Id> contactIds = new List<Id>();
for(Contact cn : cntct) {
contactIds.add(cn.Id);
}
if (fetchCalled) {
getfetch();
}
else {
taskList = 'select whoid,subject,status,LastModifiedDate from task where whoid in : contactIds order by LastModifiedDate desc';
}
List<Task> tskList = Database.query(taskList);
return tskList;
}
}
This will have only textbox for Status field (or any other field based on which you need to query the database! You have to change the query accordingly) and once you enter text and hit return ("Enter" key on Windows machine keyboards), it will query and return teh results.
Hi Manithanks for giving such valuable code .One request is that after displaying records when enter the name,,has to display link button for aany of fields.Please give ur contact no ,,based on that i lll contact u if dnt mind ThanksAnjin+919972205440 Hi Mani ,
I need to give the command lik is manually... 2)i dont want give the fetch button... when we enter the name its has display related detailscould you please give the for thisThanks in AdvanceAnjinIn that case you will need a custom controller and page as is provided in the link I gave before. Check the second approach for a simple demo using only standard objects and fields. You can of course use the same technique for Custom Objects as well! Hi Mani, Thanks for giving such valuble code. My requirement is that i need to display records details from the database..Thanks in advanceAnjin Hi Anjin,Did something similar here:https://developer.salesforce.com/forums/ForumsMain?id=906F0000000MHWbIAO2 types of search functionalities based on whether you want to search the records already being displayed on the table, or whether you want to query the database for the same. Please go through and let me know if it helps!
6 answers