You need to sign in to do that
Don't have an account?
Praveen Kumar 94
And My Apex Code
how to navigate to specific page number from inputtext? Its not working for me! Pls help
<apex:page controller="Pagnt" tabStyle="Applicant__c"> <apex:form > <apex:panelGrid id="details" > <apex:pageBlock > <apex:actionStatus id="pageStatus"> <apex:facet name="start"> <apex:outputPanel > <img src="{!$Resource.Loader}" width="80" height="20" /> <apex:outputLabel value="Loading..."/> </apex:outputPanel> </apex:facet> </apex:actionStatus> <apex:pageblockTable value="{!applist}" var="app"> <apex:column value="{!app.Name}"/> <apex:column value="{!app.First_Name__c}"/> <apex:column value="{!app.Email__c}"/> <apex:facet name="footer">Page {!pageNumber} of {!totalPages}</apex:facet> </apex:pageblockTable> Go To Page <apex:inputText value="{!num}" size="1" /> <apex:commandButton status="pageStatus" value="GO" action="{!Go}" rerender="details" /> <apex:pageblockButtons > <apex:commandButton status="pageStatus" value="First" rerender="details" action="{!First}" disabled="{!prev}"/> <apex:commandButton status="pageStatus" value="Previous" rerender="details" action="{!previous}" disabled="{!prev}"/> <apex:commandButton status="pageStatus" value="Next" rerender="details" action="{!next}" disabled="{!nxt}"/> <apex:commandButton status="pageStatus" value="Last" rerender="details" action="{!Last}" disabled="{!nxt}"/> </apex:pageblockButtons> </apex:pageBlock> </apex:panelGrid> </apex:form> </apex:page>
And My Apex Code
public with sharing class Pagnt { public void Go() { x = num ; } public Integer num { get; set; } public Integer x {get; set;} public Integer getPageNumber() { x = offsetsize/LimitSize +1 ; return x; } public Integer getTotalPages() { if (math.mod(totalRecs, Limitsize) > 0) { return totalRecs/LimitSize + 1; } else { return (totalRecs/LimitSize); } } public integer totalRecs = 0; public integer OffsetSize = 0; public integer LimitSize= 5; public Pagnt() { totalRecs = [select count() from Applicant__c]; } public List<Applicant__c> getapplist() { List<Applicant__C> app = Database.Query('SELECT Name, first_Name__C, Email__C FROM Applicant__C ORDER BY createddate ASC NULLS LAST LIMIT :LimitSize OFFSET :OffsetSize'); System.debug('Values are ' + app); return app; } public void First(){ OffsetSize = 0; } public void previous(){ OffsetSize = OffsetSize - LimitSize; } public void next(){ OffsetSize = OffsetSize + LimitSize; } public void Last(){ OffsetSize = totalrecs - math.mod(totalRecs,LimitSize); } public boolean getprev() { if(OffsetSize == 0) return true; else return false; } public boolean getnxt() { if((OffsetSize + LimitSize) > totalRecs) return true; else return false; } }
Change your Go method like following