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
Erik RodgersErik Rodgers 

Which is the preferred method of pagination. ApexPages.StandardSetController or SOQL using Offset?

I'm looking into adding pagination capabilities to a couple of our visualforce pages and was wonder which is the preferred methods for accomplishing pagination. I've seen ApexPages.StandardSetController used as well as a method using SOQL offset. Which is best or good / bad of each? Thanks.
Best Answer chosen by Erik Rodgers
Andy BoettcherAndy Boettcher
Ok, so here's my personal view / IMHO:

It's all about how you want to control the user experience and leverage the tools VF gives you.  If you want VF to control the pagination - go with the StandardSetController.  If you want to have more control, pass only the records you want to be rendered via OFFSET.

Heck, you could pass everything back via a standard or custom controller and use jQuery Datatables to handle all pagination client-side if you want.

Just my two cents. =)

All Answers

Andy BoettcherAndy Boettcher
Ok, so here's my personal view / IMHO:

It's all about how you want to control the user experience and leverage the tools VF gives you.  If you want VF to control the pagination - go with the StandardSetController.  If you want to have more control, pass only the records you want to be rendered via OFFSET.

Heck, you could pass everything back via a standard or custom controller and use jQuery Datatables to handle all pagination client-side if you want.

Just my two cents. =)
This was selected as the best answer
atla satheeshkumaratla satheeshkumar

Hi Andy Bottcher,

I have one doubt.If i would like to display 50 records on a page at atime and move forward and backward functionality through the list.
which is the preferred method(standardSetController or SOQL LIMIT with OFFSET).Please suggest me.