mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX GridFieldPaginator did not work correctly after SS_Limitable was introduced
This commit is contained in:
parent
4f1da0a5e8
commit
6d380cd546
@ -90,6 +90,8 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
||||
$state->currentPage = (int)$arguments;
|
||||
}
|
||||
|
||||
protected $totalItems = 0;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param GridField $gridField
|
||||
@ -99,9 +101,12 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
||||
public function getManipulatedData(GridField $gridField, SS_List $dataList) {
|
||||
if(!$this->checkDataType($dataList)) return $dataList;
|
||||
|
||||
$this->totalItems = $gridField->getList()->count();
|
||||
|
||||
$state = $gridField->State->GridFieldPaginator;
|
||||
if(!is_int($state->currentPage))
|
||||
if(!is_int($state->currentPage)) {
|
||||
$state->currentPage = 1;
|
||||
}
|
||||
|
||||
if(!($dataList instanceof SS_Limitable)) {
|
||||
return $dataList;
|
||||
@ -126,8 +131,7 @@ class GridFieldPaginator implements GridField_HTMLProvider, GridField_DataManipu
|
||||
$state->currentPage = 1;
|
||||
|
||||
// Figure out which page and record range we're on
|
||||
$countList = clone $gridField->List;
|
||||
$totalRows = $countList->limit(null)->count();
|
||||
$totalRows = $this->totalItems;
|
||||
if(!$totalRows) return array();
|
||||
|
||||
$totalPages = ceil($totalRows/$this->itemsPerPage);
|
||||
|
Loading…
Reference in New Issue
Block a user