Pagination using standard controller

Use case:

Show the specified number of records in a page using the standard controller.


<apex:page standardController="Account" recordSetVar="Accounts" tabStyle="Account">
    <apex:form >        <apex:pageBlock title="Edit Accounts" >            <apex:pageMessages ></apex:pageMessages>            <apex:pageBlockButtons >
              <apex:commandButton value="Save" action="{!save}"/>
              <apex:commandButton value="Cancel" action="{!cancel}"/>
            </apex:pageBlockButtons>            <apex:pageBlockTable value="{!Accounts}" var="acc">
                <apex:column value="{!}"/>                  
                <apex:column headerValue="Webiste">
                    <apex:inputField value="{!acc.Website}"/>
                </apex:column>                              </apex:pageBlockTable>            <apex:panelGrid cellpadding="5" cellspacing="5" columns="5" >                <apex:commandButton value="|<" action="{!first}"  />
                <apex:commandButton value="<" action="{!previous}" rendered="{!HasPrevious}" />
                <apex:commandButton value=">" action="{!next}" rendered="{!HasNext}" />
                <apex:commandButton value=">|" action="{!last}"  />                <apex:panelGroup >
                    <apex:outputText value="Records/Page"></apex:outputText>&nbsp;&nbsp;                    <apex:selectList value="{!PageSize}" size="1">
                        <apex:selectOption itemValue="2" itemLabel="2"></apex:selectOption>
                        <apex:selectOption itemValue="10" itemLabel="10"></apex:selectOption>
                        <apex:selectOption itemValue="15" itemLabel="15"></apex:selectOption>
                        <apex:selectOption itemValue="20" itemLabel="20"></apex:selectOption>
                    </apex:selectList>&nbsp;&nbsp;                    <apex:commandButton action="{!NULL}" value="Update Page Size"/>
                </apex:panelGroup>           </apex:panelGrid>         </apex:pageBlock>



The following are standard variables salesforce provides

recordSetVar - Stores multiple records.

first - Shows the first set of records.

previous - Shows the previous set of records.

next - Shows the next set of records.

last - Shows the last set of records.

PageSize - PageSize sets the number of records to display.

HasNext -  retunrs boolean ( true if there is next set of records available , false if there is no next set of records available ).

HasPrevious - retunrs boolean ( true if there is Previous set of records available , false if there is no Previous set of records available ).

No votes yet