分页是一种显示大量记录并将记录显示在多个页面上的技术。使用分页而不是控制每页显示的记录数。
默认情况下,列表控制器在一个页面中显示 20 个页面。为了自定义它,我们使用控制器扩展来设置页面大小。
看看下面的示例代码:
<apex:page standardController="Salary" recordSetVar="Salaries">
<apex:pageBlock title="Viewing Salaries">
<apex:form id="theForm">
<apex:pageBlockSection >
<apex:dataList var="opp" value="{!Salaries }">
{!opp.Name}
</apex:dataList>
</apex:pageBlockSection>
<apex:panelGrid columns="4">
<apex:commandLink action="{!first}">FIRST</apex:commandLink>
<apex:commandLink action="{!next}">NEXT</apex:commandLink>
<apex:commandLink action="{!previous}">PREVIOUS</apex:commandLink>
<apex:commandLink action="{!last}">LAST</apex:commandLink>
</apex:panelGrid>
</apex:form>
</apex:pageBlock>
</apex:page>