By defula displayin all the Records and When u click on alphabets is display Records state with That letter only
===================Visualforce code==================
<apex:page showHeader="false" controller="custom_paginaitonClass">
<style type="text/css">
.loadingIcon {
background-image: url(/img/loading.gif);
width: 16px;
height: 16px;
}
</style>
<script type="text/javascript">
function highlight (word) {
//alert('nnr');
document.getElementById (word.id).style.backgroundColor="#E1660D"
//alert('nnr');
}
function dehighlight (word) {
//alert('nnr');
document.getElementById (word.id).style.backgroundColor="#ffffff"
//alert('nnr');
}
</script>
<apex:form id="form">
<br/>
<center>
<div style="align:right">
<apex:repeat value="{!Alphabates}" var="A">
<apex:commandLink value="{!A}" style="text-decoration:none;" onmouseover="highlight(this);" onmouseout="dehighlight(this);" action="{!listRecords}"
reRender="pb" status="status">
<apex:param name="alpha" value="{!A}"/>
</apex:commandLink>
<apex:outputLabel style="color :Red;"> | </apex:outputLabel>
</apex:repeat>
</div>
</center>
<br/>
<apex:pageBlock id="pb">
<apex:actionStatus id="status" >
<apex:facet name="start">
<apex:outputPanel layout="block" styleClass="message infoM4">
<apex:image value="/img/loading32.gif" style="height: 15px;">please wait.........</apex:image>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
<apex:pageBlockTable value="{!contactlist}" var="c">
<apex:column value="{!c.name}"/>
<apex:column value="{!c.phone}"/>
<apex:column value="{!c.email}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
==============Controller============================
public class custom_paginaitonClass {
public string s{set;get;}
public list<Contact> contactlist { get{
contactlist=Database.Query(contactListQuery);
system.debug('333333333333333333333333333333333333333333'+contactlist);
return contactlist ;
} set; }
public string contactListQuery{get;set;}
public PageReference listRecords() {
standardSetCon = null;
if(apexpages.currentpage().getparameters().get('alpha') == 'All')
s='%';
else
s= apexpages.currentpage().getparameters().get('alpha')+'%';
contactListQuery= 'select id,name,phone,Email,Email_1__c,AccountId,Status__c from contact where name like' +'\''+s +'\''+'ORDER BY NAME DESC' + ' limit 5000';
return null;
}
public ApexPages.StandardSetController standardSetCon{
get{
if(standardSetCon==null){
standardSetCon = new Apexpages.StandardSetController(Database.getQueryLocator(contactListQuery));
standardSetCon.setPageSize(10);
}
return standardSetCon;
}
set;
}
public List<String> Alphabates { get; set; }
public custom_paginaitonClass (){
Alphabates = new string[]{'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z','ALL'};
contactListQuery= 'select id,name,phone,Email,Email_1__c,AccountId,Status__c from contact ORDER BY NAME ASC limit 1000';
}
}

No comments:
Post a Comment