function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
<apex:page controller="CustomPaginationController" sidebar="false"> <apex:form > <apex:pageBlock > <apex:pageMessages ></apex:pageMessages> <apex:pageBlockButtons > <apex:commandButton action="{!Search}" value="Search" /> </apex:pageBlockButtons> <apex:pageblockSection > <apex:inputText value="{!acc.Name}" label="Name"/> <apex:inputText value="{!acc.Phone}" label="Phone" /> </apex:pageblockSection> </apex:pageBlock> <apex:pageBlock id="resultId" rendered="{!if(lstAccount != null && lstAccount.size > 0, true,false )}"> <apex:pageBlockButtons > <div style="text-align:right"> Total Records Found: {!Con.resultSize} <apex:image url="/img/search_prevarrow_disabled.gif" styleClass="prevArrow" rendered="{!NOT(Con.HasPrevious)}"/> <apex:image url="/img/search_prevarrow.gif" title="Previous Page" styleClass="prevArrow" rendered="{!Con.HasPrevious}"/> <apex:commandLink action="{!Previous}" title="Previous Page" value="Previous Page" rendered="{!Con.HasPrevious}"/> <apex:outputPanel styleClass="pShowLess noLink" style="color:grey" rendered="{!NOT(Con.HasPrevious)}">Previous Page</apex:outputPanel> <apex:outputPanel styleClass="pShowLess noLink" style="color:grey" rendered="{!NOT(Con.HasNext)}">Next Page</apex:outputPanel> <apex:commandLink title="Next Page" value="Next Page" rendered="{!Con.HasNext}" action="{!Next}"/> <apex:image url="/img/search_nextarrow.gif" title="Next Page" styleClass="nextArrow" rendered="{!Con.HasNext}"/> <apex:image url="/img/search_nextarrow_disabled.gif" rendered="{!NOT(Con.HasNext)}"/> <img src="/s.gif" title="Last Page" alt="Last Page" class="last"/> </div> </apex:pageBlockButtons> <apex:pageBlockSection columns="1"> <apex:pageBlockTable value="{!lstAccount}" var="acc" > <apex:column value="{!acc.Name}"/> <apex:column value="{!acc.Phone}"/> </apex:PageblockTable> </apex:pageBlockSection> </apex:pageBlock> </apex:form> </apex:page>
public with sharing class CustomPaginationController { public Account acc {get;set;} public ApexPages.StandardSetController con{get; set;} public CustomPaginationController () { acc = new Account(); lstAccount = new List<Account>(); } public List<Account> lstAccount { get { if(con != null) return (List<Account>)con.getRecords(); else return null ; } set; } public PageReference Search() { String query= ''; String strFilter = ''; if(acc.Name != null && (acc.Name ).trim() !='') { strFilter = strFilter + ' where Name Like \''+acc.Name+'%\'' ; } if(acc.Phone != null && (acc.Phone).trim() !='' ) { if(strFilter == '') { strFilter = strFilter + ' where Phone like \''+acc.Phone+'%\'' ; } else { strFilter = strFilter + ' And Phone like \''+acc.Phone+'%\'' ; } } if(strFilter != '') { query = 'Select name ,id, phone from Account '+strFilter+ ' limit 1000'; System.debug('Query ---->'+ query ); con = new ApexPages.StandardSetController(Database.getQueryLocator(query)); con.setPageSize(2); } else { } return null; } public Boolean hasNext { get { return con.getHasNext(); } set; } public Boolean hasPrevious { get { return con.getHasPrevious(); } set; } public Integer pageNumber { get { return con.getPageNumber(); } set; } public void previous() { con.previous(); } public void next() { con.next(); } }
Please find the below blogs for more details on Pagination .
http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/
https://hisrinu.wordpress.com/2012/01/09/pagination-using-standardsetcontroller/
http://sfdcsrini.blogspot.com/2014/07/simple-pagenation-example-in-visualforce.html
All Answers
Please find the below blogs for more details on Pagination .
http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/
https://hisrinu.wordpress.com/2012/01/09/pagination-using-standardsetcontroller/
http://sfdcsrini.blogspot.com/2014/07/simple-pagenation-example-in-visualforce.html
1) http://amitsalesforce.blogspot.com/search/label/Pagination
Page Class
Let us know if this will help you