Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion demos/collection/grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,4 @@
});

// setting ipp with an array will add an ItemPerPageSelector to paginator
$grid->setIpp([10, 100, 1000]);
$grid->setIpp([10, 50, 100, 1000]);
15 changes: 10 additions & 5 deletions src/Grid.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class Grid extends View
public $paginator;

/** @var int Number of items per page to display. */
public $ipp = 50;
public $ipp = 10;

/**
* Calling addActionButton will add a new column inside $table, and will be re-used
Expand Down Expand Up @@ -214,13 +214,18 @@ public function setIpp($ipp, $label = 'Items per page:'): void
*
* @return $this
*/
public function addItemsPerPageSelector(array $items = [10, 100, 1000], $label = 'Items per page:')
public function addItemsPerPageSelector(array $items = [10, 50, 100, 1000], $label = 'Items per page:')
{
$ipp = (int) $this->container->stickyGet('ipp');
if ($ipp) {

/*
* If $ipp is 0 don't set $this->ipp to the first item as that always sets the viewed selection
* to the first item in the list. If we actually track the ipp in the app we want it to set and
* show the correct value, as it was before reload or other events, before this change it only set the selected ipp value but showed the first item.
* Default ipp in this class is 50, that will be showed when nothing is selected.
*/
if ($ipp > 0) {
$this->ipp = $ipp;
} else {
$this->ipp = $items[0];
}

$pageLength = ItemsPerPageSelector::addTo($this->paginator, ['pageLengthItems' => $items, 'label' => $label, 'currentIpp' => $this->ipp], ['afterPaginator']);
Expand Down
Loading