Activity Forums Salesforce® Discussions How to show Pagination ((Show more) in Custom contact inline Salesforce Visualforce Page?

  • Suraj

    Member
    May 15, 2017 at 12:21 pm

    Hi Manpreet,

    Use this code just set the index according to your requirement(how many element you want to see in the single page) and in vf page use the name of the list memList for rendering Elements.

    public class PageControlUpdated {
    public List<Contact> mem{get;set;}
    public Integer count {get;set;}
    public List<Contact> memList = new List<Contact>();
    public Integer index = 5;
    public Integer start = 0;
    public Boolean nextBool {get;set;}
    public Boolean prevBool {get;set;}

    public PageControlUpdated()
    {

    memList = [SELECT name FROM Contact];
    count = [SELECT Count() FROM Contact];
    List<Contact> temp = new List<Contact>();
    if(count<=5){
    index=count;
    prevBool=true;
    nextBool=true;
    }
    else{
    prevBool = true;
    nextBool = false;}
    for(Integer i = start; i<index; i++)
    {
    temp.add(memList.get(i));
    }
    mem = temp;

    }

    public void next()
    { if(count>5){
    index = index + 5;
    start = start + 5;}
    mem.clear();
    if(index > count)
    {
    index = Math.Mod(count,5) + start;
    system.debug('Index is ' + index);
    nextBool = true;
    prevBool = false;
    List<Contact> temp = new List<Contact>();
    for(Integer i = start; i<index; i++)
    {
    temp.add(memList.get(i));
    }
    mem = temp;
    index = start + 5;
    }
    else
    {
    List<Contact> temp = new List<Contact>();
    for(Integer i = start; i<index; i++)
    {
    temp.add(memList.get(i));
    }
    mem = temp;
    prevBool = false;
    }
    }

    public void previous()
    {
    if(start > 5)
    {
    index = index - 5;
    start = start - 5;
    List<Contact> temp = new List<Contact>();
    for(Integer i = start; i<index; i++)
    {
    temp.add(memList.get(i));
    }
    mem = temp;
    prevBool = false;
    nextBool = false;
    }
    else
    {
    index = index - 5;
    start = start - 5;
    List<Contact> temp = new List<Contact>();
    for(Integer i = start; i<index; i++)
    {
    temp.add(memList.get(i));
    }
    mem = temp;
    prevBool = true;
    nextBool = false;
    }
    }
    }

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos