+ Start a Discussion
Cheerag VijayaCheerag Vijaya 

Wrapper Class with Pagination

Hi ! I need to write a wrapper class to display records of an account with a checkbox. Along with the list of records I need to have 'next' & 'previous' buttons. In the same page I need to display the list of Accounts selected immediately whenever they are selected. 
<apex:page controller="CheckAllUsingJavascriptController">

    <script type="text/javascript">

        function selectAllCheckboxes(obj,receivedInputID){

            var inputCheckBox = document.getElementsByTagName("input");                  

            for(var i=0; i<inputCheckBox.length; i++){          


                    inputCheckBox[i].checked = obj.checked;





    <apex:form >

        <apex:pageBlock >

            <apex:pageBlockTable value="{!wrapAccountList}" var="accWrap" id="table" title="All Accounts">

                <apex:column >

                    <apex:facet name="header">

                        <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>


                    <apex:inputCheckbox value="{!accWrap.selected}" id="inputId"/>


                <apex:column value="{!accWrap.acc.Name}" />

                <apex:column value="{!accWrap.acc.BillingState}" />

                <apex:column value="{!accWrap.acc.Phone}" />
             <!-- Pagination -->
<table style="width: 100%"><tr>

       Page: <apex:outputText value=" {!PageNumber} of {! CEILING(ResultSize / PageSize) }"/>

    <td align="center">
        <!-- Previous page -->
        <!-- 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) }"/>


<!-- Next page -->
<!-- active -->
<apex:commandLink action="{! Next }" value="Next »"
     rendered="{! HasNext }"/>
<!-- inactive (no more pages) -->
<apex:outputText style="color: #ccc;" value="Next »"
     rendered="{! NOT(HasNext) }"/>
        <!-- Next page -->
    <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"/>




Amit Chaudhary 8Amit Chaudhary 8
Please check below post for same
1) http://amitsalesforce.blogspot.com/2014/11/pagination-with-wrapper-class-with.html

FOr live demo please check on below link

Let us know if this will help you
thank you sir.....