GridFieldConfigurablePaginator
class GridFieldConfigurablePaginator extends GridFieldPaginator (View source)
GridFieldConfigurablePaginator paginates the GridField list and adds controls to the bottom of the GridField. The page sizes are configurable.
Traits
Provides extensions to this object to integrate it with standard config API methods.
Provides extensions to this object to integrate it with standard config API methods.
A class that can be instantiated or replaced via DI
Config options
default_items_per_page | int | Specifies default items per page |
from GridFieldPaginator |
default_page_sizes | int | Specifies default page sizes |
Properties
protected | int | $itemsPerPage | from GridFieldPaginator | |
protected deprecated | $throwExceptionOnBadDataType | See setThrowExceptionOnBadDataType() |
from GridFieldPaginator | |
protected | $totalItems | from GridFieldPaginator | ||
protected | GridField | $gridField | ||
protected | GridState_Data | $gridFieldState | ||
protected | int[] | $pageSizes |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
Gets the uninherited value for the given config option
Determine what happens when this component is used with a list that isn't SS_Filterable.
No description
Gets the state from the current request's GridField and sets some default values on it
Add the configurable page size options to the template data
Set the first shown record number. Will be stored in the state.
Get the total number of pages, given the current number of items per page. The total
pages might be higher than
Get the page currently active. This is calculated by adding one to the previous number of pages calculated via the "first shown record" position.
Set the GridField so it can be used in other parts of the component during this request
Returns an array containing the arguments for the pagination: total rows, pages, first record etc
Returns FormActions for each of the pagination actions, in an array
Details
static Injectable
create(mixed ...$args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create(SiteTree::class); $list = SiteTree::get();
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
static Config_ForClass
config()
Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).
mixed
uninherited(string $name)
Gets the uninherited value for the given config option
__construct(int $itemsPerPage = null, int $pageSizes = null)
No description
$this
setThrowExceptionOnBadDataType(bool $throwExceptionOnBadDataType)
deprecated
deprecated
Determine what happens when this component is used with a list that isn't SS_Filterable.
- true: An exception is thrown
- false: This component will be ignored - it won't make any changes to the GridField.
By default, this is set to true so that it's clearer what's happening, but the predefined GridFieldConfig subclasses set this to false for flexibility.
bool
getThrowExceptionOnBadDataType()
deprecated
deprecated
See setThrowExceptionOnBadDataType()
protected bool
checkDataType(SS_List $dataList)
Check that this dataList is of the right data type.
Returns false if it's a bad data type, and if appropriate, throws an exception.
array
getActions(GridField $gridField)
No description
handleAction(GridField $gridField, string $actionName, array $arguments, array $data)
No description
protected GridState_Data
getGridPagerState(GridField $gridField = null)
Gets the state from the current request's GridField and sets some default values on it
void
initDefaultState(GridState_Data $data)
Initialise the default state in the given GridState_Data
We recommend that you call $data->initDefaults() to do this.
ArrayData
getTemplateParameters(GridField $gridField)
Add the configurable page size options to the template data
{@inheritDoc}
array
getHTMLFragments(GridField $gridField)
No description
$this
setItemsPerPage(int $num)
No description
int
getItemsPerPage()
No description
int
getTotalRecords()
Get the total number of records in the list
int
getFirstShown()
Get the first shown record number
$this
setFirstShown(int $firstShown = 1)
Set the first shown record number. Will be stored in the state.
int
getLastShown()
Get the last shown record number
int
getTotalPages()
Get the total number of pages, given the current number of items per page. The total
pages might be higher than
int
getCurrentPage()
Get the page currently active. This is calculated by adding one to the previous number of pages calculated via the "first shown record" position.
int
getNextPage()
Get the next page number
int
getPreviousPage()
Get the previous page number
$this
setPageSizes(array $pageSizes)
Set the page sizes to use in the "Show x" dropdown
array
getPageSizes()
Get the sizes for the "Show x" dropdown
ArrayList
getPageSizesAsList()
Gets a list of page sizes for use in templates as a dropdown
GridField
getGridField()
Get the GridField used in this request
$this
setGridField(GridField $gridField)
Set the GridField so it can be used in other parts of the component during this request
protected array
getPagerArguments()
Returns an array containing the arguments for the pagination: total rows, pages, first record etc
GridField_FormAction[]
getPagerActions(array $controls, GridField $gridField)
Returns FormActions for each of the pagination actions, in an array