You need to sign in to do that
Don't have an account?
aress
Visual force page for Account object
Can anyone help me in code for designing VF page with following functionalities.?
The account manager now wants the function to search for a particular account from the account list page.
Add a textbox to the top of the VF page that will take the account name. Add a button as well that will perform the search on the accounts and display the results accordingly. The count of the accounts should also be updated.
The search should also be performed on pressing the enter button on the keyboard. If nothing has been entered in the textbox, a message should be displayed stating that “Input at least 3 characters to perform search”.
The results of the search should be displayed without refreshing the page. Also add a link to clear the search results.
The account manager now wants the function to search for a particular account from the account list page.
Add a textbox to the top of the VF page that will take the account name. Add a button as well that will perform the search on the accounts and display the results accordingly. The count of the accounts should also be updated.
The search should also be performed on pressing the enter button on the keyboard. If nothing has been entered in the textbox, a message should be displayed stating that “Input at least 3 characters to perform search”.
The results of the search should be displayed without refreshing the page. Also add a link to clear the search results.
I Hope the Below Code will Fit your Requirement.Let me Know if you face any Issues Regarding this.
/**************************************Apex Class****************************************/
public class FetchRecords
{
public String InputBox{get;set;}
public List<Account> AccountList{get;set;}
public Integer AccSize{get;set;}
public String MatchString;
public void FetchRecordsMethod(){
MatchString = '%'+ InputBox +'%';
AccountList = [SELECT Id,Name FROM Account WHERE Name LIKE :MatchString ];
System.debug('***AccList' + AccountList );
AccSize = AccountList.size();
}
}
/**************************************Visual Forece Page****************************************/
<apex:page controller="FetchRecords" >
<apex:form >
<script type='text/javascript'>
function noenter(ev) {
if (window.event && window.event.keyCode == 13 || ev.which == 13) {
KeyPressCall();
return false;
} else {
return true;
}
}
</script>
<apex:pageBlock title="Pirate Account">
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="Search" action="{!FetchRecordsMethod}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:actionFunction action="{!FetchRecordsMethod}" name="KeyPressCall"/>
<apex:inputText label="Search value" value="{!InputBox}" onkeypress="return noenter(event);"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Results" >
<apex:pageBlockTable value="{!AccountList}" var="site" >
<apex:column value="{!site.Name}"/>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Kindly Mark this as a Best Answer if you Find this Useful!
Thanks
DineshKumar Gopalakrishnan