Dynamically configure per page options (#5528)

* added perPageOptions to allowed config attributes

* Update Lists.php

Updated List Widget to be able to change perPageOptions according to lists config
This commit is contained in:
thomas4Bitcraft 2021-03-05 02:29:27 +01:00 committed by GitHub
parent daf281df41
commit 9d06eb5c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

View File

@ -145,6 +145,7 @@ class ListController extends ControllerBehavior
'recordUrl',
'recordOnClick',
'recordsPerPage',
'perPageOptions',
'showPageNumbers',
'noRecordsMessage',
'defaultSort',

View File

@ -62,6 +62,12 @@ class Lists extends WidgetBase
* @var int Maximum rows to display for each page.
*/
public $recordsPerPage;
/**
* @var array Options for number of items per page.
*/
public $perPageOptions;
/**
* @var bool Shows the sorting options for each column.
@ -199,6 +205,7 @@ class Lists extends WidgetBase
'noRecordsMessage',
'showPageNumbers',
'recordsPerPage',
'perPageOptions',
'showSorting',
'defaultSort',
'showCheckboxes',
@ -1689,7 +1696,7 @@ class Lists extends WidgetBase
*/
protected function getSetupPerPageOptions()
{
$perPageOptions = [20, 40, 80, 100, 120];
$perPageOptions = is_array($this->perPageOptions) ? $this->perPageOptions : [20, 40, 80, 100, 120];
if (!in_array($this->recordsPerPage, $perPageOptions)) {
$perPageOptions[] = $this->recordsPerPage;
}