function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Simha YadavSimha Yadav 

please request anybody to add pagination code for below code....

VF Code:
<apex:page standardController="Account" extensions="WrapperDemoClass" showHeader="false" sidebar="false">
  <script type="text/javascript">
        function selectAllCheckboxes(obj,receivedInputID){
            var inputCheckBox = document.getElementsByTagName("input");                  
            for(var i=0; i<inputCheckBox.length; i++){          
                if(inputCheckBox[i].id.indexOf(receivedInputID)!=-1){                                     
                    inputCheckBox[i].checked = obj.checked;
                }
            }
        }
    </script>
  <apex:form >
    <apex:pageBlock title=" Account Invoice" id="pgBlckId">
    <br/>
    <br/>
     <apex:commandButton value="Send Email" action="{!sendEmail}" reRender="pgBlckId" status="actStatusId" />
     &nbsp;
       <apex:actionStatus id="actStatusId" >
       <apex:facet name="start" >
       <apex:image url="{!$Resource.Image}"/>
       </apex:facet>
       </apex:actionStatus>
     <br/>
     <br/>
     <apex:pageMessages />
     <br/>
       <apex:pageblockTable value="{!wrapperObj}" var="Rec" id="table" title="All Accounts">
         <apex:column >      
         <apex:facet name="header">
         <apex:inputCheckbox onclick="selectAllCheckboxes(this,'inputId')"/>
         </apex:facet>
         <apex:inputCheckbox value="{!Rec.checkBox}" id="inputId"/>
         </apex:column>
         <apex:column value="{!Rec.accObj.name}"/>
         <apex:column value="{!Rec.accObj.phone}"/>
         <apex:column value="{!Rec.accObj.Email__c}"/>
         <apex:column value="{!Rec.accObj.createddate}"/>
         <apex:column value="{!Rec.accObj.Email_Status__c}"/>
      </apex:pageblockTable> 
    </apex:pageblock>
  </apex:form>
</apex:page>

Apex Class:

public with sharing class WrapperDemoClass {
    Public List<WrapperClassEx> WrapperList{get;set;}
    public List<Account> accList {get;set;}
    public boolean checked {get;set;}
    public WrapperDemoClass(ApexPages.StandardController controller) {
      
    }
   
   Public List<WrapperClassEx> getwrapperObj(){
      accList = [Select id,name,phone,type,industry,Email__c,createddate,Email_Status__c from account limit 15];
      WrapperList = New List<WrapperClassEx>();
      for(Account acc: accList){
        WrapperList.add(New WrapperClassEx(acc,false)); 
      }
      system.debug('WrapperList :'+WrapperList);
      return WrapperList;
   }
   
   public void sendEmail(){
     List<Messaging.SingleEmailMessage> lstEmailId=new List<Messaging.SingleEmailMessage>();
     
         PageReference pdf = Page.newreq;
        // add parent id to the parameters for standardcontroller
        //pdf.getParameters().put('id',accountId);
    
        // the contents of the attachment from the pdf
        Blob body;
    
        try {
    
          // returns the output of the page as a PDF
          body = pdf.getContent();
    
        // need to pass unit test -- current bug  
        } catch (VisualforceException e) {
          body = Blob.valueOf('Some Text');
        }
    
       
     
     for(WrapperClassEx w: WrapperList){
        system.debug('w.checkBox :'+w.checkBox);
        if(w.checkBox == true){
            
            Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
            attach.setContentType('application/pdf');
            attach.setFileName('Invoice.pdf');
            attach.setInline(false);
            attach.Body = body;
            
            Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
            mail.setToAddresses(new String[] {w.accObj.Email__c});
            //mail.setReplyTo('sumit.shukla@magicsw.com');
            mail.setplainTextBody('Hello');
            mail.setSenderDisplayName('Your Company Name');
            mail.setSubject('Test Email From Force.com Sites');
            mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach }); 
            lstEmailId.add(mail);
            system.debug('lstEmailId :'+lstEmailId);                        
        }
      }
        if(lstEmailId.size()>0){
            try{
                Messaging.sendEmail(lstEmailId);
                checked = true;
                ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Confirm,'Sent!'));
            }Catch(Exception ee){
                ApexPages.AddMessage(new ApexPages.Message(ApexPages.Severity.Error,ee.getMessage()));
            }
            
        }
      
    }     
   

  
   Public Class WrapperClassEx{
     Public Account accObj{get;set;}
     Public Boolean checkBox{get;set;}
    
     Public WrapperClassEx(Account accRec, boolean SelectBox){
        accObj = accRec;
        checkBox = SelectBox;
     }
   }
}


 
Abhishek BansalAbhishek Bansal
Hi,

Please find help on the below mentioned links :
  1. https://developer.salesforce.com/docs/atlas.en-us.knowledge_dev.meta/knowledge_dev/knowledge_customize_searchpage_visualforce_02pagination.htm
  2. https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_controller_sosc_pagination.htm
Just go through these links and you will find methods of pagination which you can copy and paste into your page and class.

Let me know if you need more help on this

Thanks,
Abhishek
Chandra Sekhar CH N VChandra Sekhar CH N V
Give a try for Jquery :
 
//insert the below after <apex:tag>
<apex:stylesheet value="{!URLFOR($Resource.JQueryResource, 'css/jquery.dataTables.css')}"/> 
<apex:stylesheet value="{!URLFOR($Resource.JQueryResource, 'css/jquery.demo_page.css')}"/>  
<apex:stylesheet value="{!URLFOR($Resource.JQueryResource, 'css/jquery.demo_table.css')}"/> 
<apex:stylesheet value="{!URLFOR($Resource.JQueryResource, 'css/dataTables.tableTools.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.JQueryResource, 'css/dataTables.tableTools.min.css')}"/>
<apex:includeScript value="{!URLFOR($Resource.JQueryResource, 'js/jquery.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.JQueryResource, 'js/jquery.dataTables.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.JQueryResource, 'js/dataTables.tableTools.js')}"/>
<apex:includeScript value="{!URLFOR($Resource.JQueryResource, 'js/dataTables.tableTools.min.js')}"/>
   <apex:includeScript value="{!URLFOR($Resource.JQueryResource, 'js/jquery-1.9.0.min.js')}"/>


//inside script tag

jQuery(document).ready(function() {
        jQueryMethod();
    });

    function jQueryMethod(){
        var j$ = jQuery.noConflict();
         j$('table.casedataTable').dataTable({  
        });

    jQuery(".content").show();
    //toggle the componenet with class msg_body
    jQuery(".heading").click(function()
    {
        jQuery(this).next(".content").slideToggle(500);
    });

    }


//include the below in pageblocktable tag

StyleClass="casedataTable"

 
Simha YadavSimha Yadav
no its getting error Mr chandra shekar...
Chandra Sekhar CH N VChandra Sekhar CH N V
what's the error?