Controllerクラス内で、StandardSetControllerを作成したら
setPageSize()で1ページあたりに表示する最大レコード数をセットします。
next()で次のページへ、
previous()で前のページへ、
first()で最初のページへ、
last()で最後のページへ、
getHasNext()で次のページがあるかどうかを取得、
getHasPrevious()で前のページがあるかどうかを取得、
getPageNumber()で現在のページ番号を取得、
getResultSize()で総レコード数を取得
/*
*
* 画面表示用リストを作成
*
*/
private void makeDisClass( List<PlantApply__c> results ){
// 表示用リスト
this.disList = new List<DisClass>();
// 選択されたのレコードID
this.selectedId = null;
// 表示用リストを作成する
for( PlantApply__c pa : results ){
this.disList.add(new DisClass(pa,false));
}
// 該当画面番号
currentPageNo = setCon.getPageNumber();
resultSize = setCon.getResultSize();
if(currentPageNo*PAGESIZE > resultSize){
showMaxSize = resultSize;
}else{
showMaxSize = currentPageNo*PAGESIZE+1;
}
}
ページ番号表示
public List<Integer> getPageNo(){
Integer disNo = 4;
List<Integer> noList = new List<Integer>();
// 総頁数
Integer totalPageNo = (Integer)((Decimal)resultSize/PAGESIZE).round(System.RoundingMode.UP);
// Loop回数
Integer roundPageNo = (Integer)((Decimal)currentPageNo/disNo).round(System.RoundingMode.UP);
// 開始頁数
Integer pageStartNo = ( roundPageNo == 1 ? 1 : roundPageNo * disNo - disNo + 1 );
// 終了頁数
Integer pageEndNo = ( roundPageNo*disNo > totalPageNo ? totalPageNo : roundPageNo*disNo );
for( Integer i = pageStartNo; i <= pageEndNo; i++ ){
noList.add(i);
}
return noList;
}