Skip to content

Commit

Permalink
Minor changes for rendering pager, we are now using data from `yii\da…
Browse files Browse the repository at this point in the history
…ta\Pagination` and as a last resort, in case there is no Pagination, we are using data from DataProvider.
  • Loading branch information
microThread committed Jan 10, 2018
1 parent 19a4e4b commit 518af87
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/renderer/GridViewRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,15 +88,22 @@ public function renderSection($name)
public function renderPager()
{
$pagination = $this->grid->dataProvider->getPagination();
$totalResults = $this->grid->dataProvider->getTotalCount();
$resultsPerPage = $this->grid->dataProvider->getCount();
$totalResults = 0;
$resultsPerPage = 0;
$totalPages = 1;
$currentPage = 1;

if (isset($pagination) && is_object($pagination) == true)
if (isset($pagination) && is_object($pagination))
{
$totalPages = $pagination->pageCount;
$currentPage = $pagination->page + 1;
$totalResults = $pagination->totalCount;
$resultsPerPage = $pagination->getPageSize();
$totalPages = $pagination->getPageCount();
$currentPage = $pagination->getPage() + 1;

} else
{
$totalResults = $this->grid->dataProvider->getTotalCount();
$resultsPerPage = $this->grid->dataProvider->getCount();
}

return [
Expand Down

0 comments on commit 518af87

Please sign in to comment.