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
Varun99Varun99 

Pagination

Hi,

     I am displaying all contacts using list in a pageblock table. and when i click on contact names

it will show the output fields(detail page) of particular record. So i want to pagination in this detail page

next, previous clicking on next it will show next record detail page.clicking on previous it will show previous recored detail page. so how to add the displaying contact list to pagination query.

 

please help me.

 

My code

=====================

<apex:page controller="classcon" sidebar="false" showHeader="false">
<apex:form >
<apex:pageBlock rendered="{!clist}">
<apex:dataTable value="{!conlist}" var="c" >

<apex:column headerValue="contacts" >
<apex:commandLink value="{!c.name}" action="{!condetail}">
<apex:param name="conname" value="{!c.id}"/>
</apex:commandLink>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
<apex:pageBlock rendered="{!cdetail}" >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="edit" action="{!edit}"/>
<apex:commandButton value="back" action="{!back}"/>
</apex:pageBlockButtons>
<apex:pageblockSection >
<apex:repeat value="{!con2}" var="ac">
<apex:param value="{!ac.id}"/>
<apex:outputfield value="{!ac.lastname}"/>
<apex:outputfield value="{!ac.phone}"/>
<apex:outputfield value="{!ac.email}"/>
</apex:repeat>
</apex:pageblockSection>
</apex:pageBlock>
<apex:panelGrid >
<apex:commandLink action="{!previous}" rendered="{!hasPrevious}"><b>Previous</b></apex:commandlink>
<apex:commandLink action="{!next}" rendered="{!hasnext}"><b>Next</b></apex:commandlink>
</apex:panelGrid>
<apex:pageBlock rendered="{!cedit}" >
<apex:pageBlockButtons location="bottom">
<apex:commandButton value="save" action="{!save}"/>
<apex:commandButton value="back" action="{!back}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection >
<apex:repeat value="{!con2}" var="ab">
<apex:inputfield value="{!ab.lastname}"/>
<apex:inputfield value="{!ab.phone}"/>
<apex:inputfield value="{!ab.email}"/>
</apex:repeat>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

 

============================================

public class classcon {
list<contact> conlist=new list<contact>();
public boolean clist {set;get;}
public boolean cdetail{set;get;}
public boolean cedit{set;get;}
//public boolean bcc{set;get;}
public ApexPages.StandardSetController con1{set;get;}
//list<contact> con=new list<contact>();

public classcon(){
clist=true;
cdetail=false;
cedit=false;

conlist=[select id,lastname,name,phone,email from contact];
}
public list<contact> getconlist(){return conlist;}
public Boolean hasNext{get{return con.getHasNext();}set;}
public Boolean hasPrevious{get{return con.getHasPrevious();}set;}

public ApexPages.StandardSetController con {
get {
if(con==null)
{
con = new ApexPages.StandardSetController(Database.getQueryLocator([Select id,name,lastname,phone,email FROM Contact where id in:conlist]));
con.setPageSize(1);
system.debug('@@@@@@'+con);
}
return con;

}
set;

}

public void condetail()
{

id i=apexpages.currentpage().getparameters().get('conname');
system.debug('+++++++++++++++++++++'+con);
clist=false;
cdetail=true;
cedit=false;

con2=new contact();
con2=[select id,lastname,phone,email from contact where id=:i];
}
public contact con2{get;set;}


public void edit()
{
clist=false;
cdetail=false;
cedit=true;
}

public void save(){

clist=false;
cdetail=true;
cedit=false;
update con2;
}
public void back(){

clist=true;
cdetail=false;
cedit=false;
}
public void next()
{

con.next();
}
public void previous()
{
con.previous();
}
}

 

 

 

Sourabh_Master10Sourabh_Master10

Hi,

See these links:-
http://blog.jeffdouglas.com/2009/07/14/visualforce-page-with-pagination/

if you think that answer is right then please tick the answers.
Thanks
Sourabh

Varun99Varun99

 

Hi sourabh Master,

                                    I have searched that blog but am using a list to displaying contacts how to add this list to pagination.

please help me.

 

Thank you