You need to sign in to do that
Don't have an account?
Ap30
Next and previous in Apex
Hello All,
In standard view we should see only one record at a time. On clicking next button, it should show another single record. Record shown first should not be there. I couldn't implement as i'm new to pagination concept.Please help.
<apex:page standardController="obj__c" extensions="contollername">
<apex:form >
<apex:pageBlock title="Student's Data">
<apex:pageBlockTable value="{!listitem}" var="sd">
<apex:column value="{!sd.First_Name__c}"/>
<apex:column value="{!sd.Last_Name__c}"/>
<apex:column value="{!sd.Company__c}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton action="{!previous}" value="Prev"/>
<apex:commandButton action="{!next}" value="Next"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
======================
public class contollername
{
public transient List<obj__c> listitem{get; set;}
public Integer size {get; set;}
public contollername(ApexPages.StandardController stdController) {
size=1;
setLists();
}
public void setLists()
{
listitem= [Select First_Name__c,Last_Name__c,Company__c From obj__c limit:size];
}
public void next()
{
setLists();
}
public void previous()
{
setLists();
}
}
In standard view we should see only one record at a time. On clicking next button, it should show another single record. Record shown first should not be there. I couldn't implement as i'm new to pagination concept.Please help.
<apex:page standardController="obj__c" extensions="contollername">
<apex:form >
<apex:pageBlock title="Student's Data">
<apex:pageBlockTable value="{!listitem}" var="sd">
<apex:column value="{!sd.First_Name__c}"/>
<apex:column value="{!sd.Last_Name__c}"/>
<apex:column value="{!sd.Company__c}"/>
</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton action="{!previous}" value="Prev"/>
<apex:commandButton action="{!next}" value="Next"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
======================
public class contollername
{
public transient List<obj__c> listitem{get; set;}
public Integer size {get; set;}
public contollername(ApexPages.StandardController stdController) {
size=1;
setLists();
}
public void setLists()
{
listitem= [Select First_Name__c,Last_Name__c,Company__c From obj__c limit:size];
}
public void next()
{
setLists();
}
public void previous()
{
setLists();
}
}
Check below example that matches your requirement :-
https://developer.salesforce.com/forums/?id=906F0000000BZxWIAW
Please mark as Best Answer so that it can help others in the future.
Regards,
Priya Ranjan
All Answers
Check below example that matches your requirement :-
https://developer.salesforce.com/forums/?id=906F0000000BZxWIAW
Please mark as Best Answer so that it can help others in the future.
Regards,
Priya Ranjan