Skip to main content The Trailblazer Community will be unavailable from 2/1/2025 to 2/2/2025. Please plan your activities accordingly.
I am having problems with the example of a visulforce page that has pagination.  They don't show how the completed page should look, and I am sure something is wrong, but I don't know what.  I have googled and looked in forums and in help, but there are no anwers I can find  to create a self contained visualforce page that displays contacts with pagination.  Everything works great, but no pagination.

Can anyone point me to where I can find the completed source code?  These trails usually show you what your completed code looks like, but this one doesn't.  I am not looking for anwers to a challenge, but just what I am doing wrong.

Thank you!  

Here is my code:

<apex:page standardController="Contact" recordSetVar="contacts">

    <apex:form>

    <apex:pageBlock title="Contacts List" id="contacts_list">

        

Filter:

   <apex:selectList value="{! filterid }" size="1">

       <apex:selectOptions value="{! listviewoptions }"/>    

       <apex:actionSupport event="onchange" reRender="contacts_list"/>

   </apex:selectList>        

        

        <!-- Contacts List -->

        <apex:pageBlockTable value="{! contacts }" var="ct">

            

         <!-- pagination -->

         <table style="width: 100%">

         <tr>

             <td>

                 <!-- page X of Y -->

                 page: <apex:outputText value=" {!PageNumber} of {! ceiling(resultsize / pagesize) } "/>

             </td>

             

             <td align="center">

                 <!-- Previous page -->

                 <!-- active -->

                 <apex:commandLink action="{! Previous }" value="« Previous"

                                   Rendered="{! HasPrevious }"/>    

                 <!-- inactive (no earlier pages) -->

                 <apex:outputText style="color: ⌗ccc;" value="« Previous"

                 rendered="{! NOT(HasPrevious) }" />

&nbsp;&nbsp;

                 

                 <!-- Next page -->

                 <apex:commandLink action="{! Next }" value="Next »"

                                   Rendered="{! HasNext }"/>    

                 <!-- inactive (no earlier pages) -->

                 <apex:outputText style="color: ⌗ccc;" value="Next »"

                 rendered="{! NOT(HasNext) }" />

                 

             </td>

             

             <td align="right">

                 <!-- Records per page -->

Records per page:

              <apex:selectList value="{! PageSize }" size="1">

                  <apex:selectOption itemValue="5" itemLabel="5"/>

                  <apex:selectOption itemValue="20" itemLabel="20"/>

                  <apex:actionSupport event="onchange" reRender="contacts_list"/>

              </apex:selectList>   

                 

             </td>

         </tr>    

          </table>

            

          <apex:column value="{! ct.firstname }"/>

          <apex:column value="{! ct.lastname }"/>

          <apex:column value="{! ct.email }"/>

          <apex:column value="{! ct.account.name }"/>

          <apex:column value="{! ct.birthdate }"/>

        </apex:pageBlockTable>

        

    </apex:pageBlock>

</apex:form>    

    

    

</apex:page>
6 answers
  1. Mar 31, 2016, 11:18 PM
    Hi Suzi,

    You'll want to take all the pagination code and move it outside (below) </apex:pageBlockTable>. The only thing remaining inside that tag should be the <apex:column> values.

    Because that tag iterates over every Contact, you don't want it rendering the pagination controls X number of times, just once

    Also follow my above post for working example.

    Regards,

    Mahesh
Loading
0/9000