Any Idea of how to create pagination in custom related list.Here is my page and class. I need to display 5 oppty records.If there are more than 5 records then i need to show a link Show More link which goes to next page and displays all records like below.
public class sampleDetailPageCon { private List<Opportunity> oppz; private Contact cntact; public sampleDetailPageCon(ApexPages.StandardController controller) { this.cntact= (Contact)controller.getRecord(); } public List<Opportunity> getOppz() { Contact con = [Select id, Account.id FROM Contact where id = :cntact.id]; if (con.Account == null) return null; oppz = [Select id, Name, Account.Name, CloseDate, Amount, Type from Opportunity where Account.id = :con.Account.id]; return oppz; } }
You can use a StandardSetController to create pagination functionality in Visualforce Pages.
StandardSetController lets you do things like set the number of recrods in a page, prev/next methods, and other functionalilty specifically needed for paginations.
You can use a standard apex controller class, and inside that class have your STandardSetController which does pagination.
public with sharing class OpptyExtension
{
public Opportunity oppty {get;set;}
public StandardSetController paginationController {get;set;}
public OpptyExtnesion(ApexPages.standardController std)
{
oppty = std.getRecord();
paginationController = new StandardSetController([Select Id, Name from Deal__c where Opportunity__c =: oppty.Id]; }
public void next()
{
paginationController.next();
}
public void prev()
{
paginationController.prev();
}
}
Then in your VF page you bind a DataTable to the results Sets.
You can use a StandardSetController to create pagination functionality in Visualforce Pages.
StandardSetController lets you do things like set the number of recrods in a page, prev/next methods, and other functionalilty specifically needed for paginations.
You can use a standard apex controller class, and inside that class have your STandardSetController which does pagination.
public with sharing class OpptyExtension
{
public Opportunity oppty {get;set;}
public StandardSetController paginationController {get;set;}
public OpptyExtnesion(ApexPages.standardController std)
{
oppty = std.getRecord();
paginationController = new StandardSetController([Select Id, Name from Deal__c where Opportunity__c =: oppty.Id];
}
public void next()
{
paginationController.next();
}
public void prev()
{
paginationController.prev();
}
}
Then in your VF page you bind a DataTable to the results Sets.