Skip to content

A simple framework to apply pagination in visualforce pages

Notifications You must be signed in to change notification settings

sharathkmr/visualforce-pagination

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 

Repository files navigation

visualforce-pagination

Step 1

Extend the controller class to SObjectPaginator for which you want to implement pagination and implement the methods

void begingList();
void nextList();
void prevList();
void lastList();
  • Extending the controller class to SObject Paginator

Image 1

  • Implement the abstract methods

Image 2

Step 2

  • set the limit size by calling super class contructor.
  • set the records of the list for which you want to apply pagination using the following method and call run() method
// set limit size
super(20);

// set the records
void setRecords(List<SObject>);

// call the run() method
run();

Image 3

Step 3

  • Initially when you pass the list of SObject records you want to paginate, the SObjectPaginator will create an initial list consisting of 1st limit size records.
  • get the records by accessing the limitRecords list using getLimitRecords() method which will return List of SObjects.
  • after getting the records you need to cast the SObject to your respective SObject type.

Image 4

Step 4

  • Implement the abstract methods in controller
public void begingList();
public void nextList();
public void prevList();
public void lastList();
  • call the beginning(), next(), previous() and last() super class methods in the begingList(), nextList(), prevList() and lastList() methods respectively.
  • After calling the methods, get the limitRecords list from the SObjectPaginator using getLimitRecords() method which will return List of SObjects and cast the SObject to respective SObject type
  • Dont forget to clear the list in your controller class in every method.

Image 5

Step 5

  • Comming to the visualforce page, you can call the methods begingList(), nextList(), prevList() and lastList() implemented in your controller class.
  • To disable the pagination buttons dynamically according to the list you can bind disabled attribute with the getDisableNext() and getDisablePrevious() methods available in SObjectPaginator class.
public Boolean getDisableNext()
public Boolean getDisablePrevious()

Image 6

Reference

  • you can go through the visualforce page and controller examples for implementation

Visualforce Page

Controller

SObjectPaginator Class

About

A simple framework to apply pagination in visualforce pages

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages