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
RiapatelRiapatel 

Pageblocktable

Hi, I want to retrieve only 10 records at a time using pageblocktable. Do i have to use a List for that? Any sample code is appreciated. Thanks. 
Best Answer chosen by Riapatel
James LoghryJames Loghry
For this functionality, I typically default to utilizing a standardsetcontroller and it's baked in pagination functionality.  (You can even set the page size to whatever you'd like) There are several examples out there, here's the best one I came across in my brief search: http://saramorgan.net/2014/11/11/pagination-and-the-standardsetcontroller-no-custom-controller-required/

All Answers

Jag@SFJag@SF
H​ave you tried using "rows" attribute? For example,
<apex:pageBlockTable value="{!account.Contacts}" var="item" rows="10">
      <apex:column value="{!item.field1}"/>
</apex:pageBlockTable>



 
James LoghryJames Loghry
For this functionality, I typically default to utilizing a standardsetcontroller and it's baked in pagination functionality.  (You can even set the page size to whatever you'd like) There are several examples out there, here's the best one I came across in my brief search: http://saramorgan.net/2014/11/11/pagination-and-the-standardsetcontroller-no-custom-controller-required/
This was selected as the best answer
RiapatelRiapatel
Thanks Jag@SF and James. That worked!