Pagination of Wrapper Class Objects
- <div>
- <apex:panelGroup >
- <apex:commandLink action="{!First}" reRender="pb">
- <apex:image value="{!$Resource.First}" height="20px" width="60px" title="First" />
- </apex:commandLink>
- <apex:commandLink action="{!Previous}" reRender="pb">
- <apex:image value="{!$Resource.Previous}" height="20px" width="40px" title="Previous" rendered="{!hasPrevious}"/>
- </apex:commandLink>
- <apex:outputLabel style="font-size:17px; margin-bottom:0px;" > Page {!pageno} (Page 1 - Page {!lastPageno }) </apex:outputLabel>
- <apex:commandLink action="{!Next}" reRender="pb">
- <apex:image value="{!$Resource.Next}" height="20px" width="40px" title="Next" rendered="{!hasNext}"/>
- </apex:commandLink>
- <apex:commandLink action="{!Last}" reRender="pb">
- <apex:image value="{!$Resource.Last}" height="20px" width="60px" title="Last" />
- </apex:commandLink>
- </apex:panelGroup>
- </div>
Public Boolean hasPrevious {get;set;}
Public Boolean hasNext {get;set;}
Public Integer pageno {get;set;}
Public Integer lastPageno {get;set;}
public PageReference Last() {
pageno = lastPageno;
listToDisplay();
return null;
}
public PageReference Next() {
pageno++;
listToDisplay();
return null;
}
public PageReference Previous() {
pageno--;
listToDisplay();
return null;
}
public PageReference First() {
pageno = 1;
listToDisplay();
return null;
}
lastPageno = lstWS.size()/10; // Page size 10 rows
if(lastPageno*10 < lstWS.size())
lastPageno++;
if(pageno < lastPageno )
hasNext = true;
else
hasNext = false;
if(pageno > 1 )
hasPrevious = true;
else
hasPrevious = false;
listToDisplay();
- public void listToDisplay()
- {
- if(pageno < lastPageno )
- hasNext = true;
- else
- hasNext = false;
- if(pageno > 1 )
- hasPrevious = true;
- else
- hasPrevious = false;
- lstWSTenSize = new List<wrapStudent>();
- If(pageNo*10 < lstWS.size())
- {
- for (Integer i = ((pageNo*10)-10); i<pageNo*10; i++ )
- {
- lstWSTenSize.add(lstWS[i]);
- }
- }
- else If(pageNo*10 >= lstWS.size())
- {
- for (Integer i = ((pageNo*10)-10); i<lstWS.size(); i++ )
- {
- lstWSTenSize.add(lstWS[i]);
- }
- }
- }
Comments
Post a Comment