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

public static 
create(mixed ...$args)

An implementation of the factory method, allows you to create an instance of a class

public static 
singleton(string $class = null)

Creates a class instance by the "singleton" design pattern.

public static 
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public
__construct(int $itemsPerPage = null, int $pageSizes = null)

No description

public
$this
setThrowExceptionOnBadDataType(bool $throwExceptionOnBadDataType) deprecated

Determine what happens when this component is used with a list that isn't SS_Filterable.

public
bool
getThrowExceptionOnBadDataType() deprecated

See setThrowExceptionOnBadDataType()

protected
bool
checkDataType(SS_List $dataList)

Check that this dataList is of the right data type.

public
array
getActions(GridField $gridField)

No description

public
handleAction(GridField $gridField, string $actionName, array $arguments, array $data)

No description

protected
getGridPagerState(GridField $gridField = null)

Gets the state from the current request's GridField and sets some default values on it

public
void
initDefaultState(GridState_Data $data)

Initialise the default state in the given GridState_Data

public
getManipulatedData(GridField $gridField, SS_List $dataList)

No description

public
getTemplateParameters(GridField $gridField)

Add the configurable page size options to the template data

public
array
getHTMLFragments(GridField $gridField)

No description

public
$this
setItemsPerPage(int $num)

No description

public
int
getItemsPerPage()

No description

public
int
getTotalRecords()

Get the total number of records in the list

public
int
getFirstShown()

Get the first shown record number

public
$this
setFirstShown(int $firstShown = 1)

Set the first shown record number. Will be stored in the state.

public
int
getLastShown()

Get the last shown record number

public
int
getTotalPages()

Get the total number of pages, given the current number of items per page. The total pages might be higher than / if the first shown record is half way through a standard page break point.

public
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.

public
int
getNextPage()

Get the next page number

public
int
getPreviousPage()

Get the previous page number

public
$this
setPageSizes(array $pageSizes)

Set the page sizes to use in the "Show x" dropdown

public
array
getPageSizes()

Get the sizes for the "Show x" dropdown

public
getPageSizesAsList()

Gets a list of page sizes for use in templates as a dropdown

public
getGridField()

Get the GridField used in this request

public
$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

public
getPagerActions(array $controls, GridField $gridField)

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();

Parameters

mixed ...$args

Return Value

Injectable

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).

Parameters

string $class

Optional classname to create, if the called class should not be used

Return Value

Injectable

The singleton instance

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

__construct(int $itemsPerPage = null, int $pageSizes = null)

No description

Parameters

int $itemsPerPage
  • How many items should be displayed per page
int $pageSizes

The page sizes to show in the dropdown

$this setThrowExceptionOnBadDataType(bool $throwExceptionOnBadDataType) deprecated

deprecated 5.2.0 Will be removed without equivalent functionality

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.

Parameters

bool $throwExceptionOnBadDataType

Return Value

$this

bool getThrowExceptionOnBadDataType() deprecated

deprecated 5.2.0 Will be removed without equivalent functionality

See setThrowExceptionOnBadDataType()

Return Value

bool

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.

Parameters

SS_List $dataList

Return Value

bool

array getActions(GridField $gridField)

No description

Parameters

GridField $gridField

Return Value

array

with action identifier strings.

handleAction(GridField $gridField, string $actionName, array $arguments, array $data)

No description

Parameters

GridField $gridField
string $actionName

Action identifier, see getActions().

array $arguments

Arguments relevant for this

array $data

All form data

protected GridState_Data getGridPagerState(GridField $gridField = null)

Gets the state from the current request's GridField and sets some default values on it

Parameters

GridField $gridField

Return Value

GridState_Data

void initDefaultState(GridState_Data $data)

Initialise the default state in the given GridState_Data

We recommend that you call $data->initDefaults() to do this.

Parameters

GridState_Data $data

The top-level state object

Return Value

void

SS_List getManipulatedData(GridField $gridField, SS_List $dataList)

No description

Parameters

GridField $gridField
SS_List $dataList

Return Value

SS_List

ArrayData getTemplateParameters(GridField $gridField)

Add the configurable page size options to the template data

{@inheritDoc}

Parameters

GridField $gridField

Return Value

ArrayData

If paging is available this will be an ArrayData object of paging details with these parameters:

  • OnlyOnePage: boolean - Is there only one page?
  • FirstShownRecord: integer - Number of the first record displayed
  • LastShownRecord: integer - Number of the last record displayed
  • NumRecords: integer - Total number of records
  • NumPages: integer - The number of pages
  • CurrentPageNum (optional): integer - If OnlyOnePage is false, the number of the current page
  • FirstPage (optional): GridField_FormAction - Button to go to the first page
  • PreviousPage (optional): GridField_FormAction - Button to go to the previous page
  • NextPage (optional): GridField_FormAction - Button to go to the next page
  • LastPage (optional): GridField_FormAction - Button to go to last page

array getHTMLFragments(GridField $gridField)

No description

Parameters

GridField $gridField

Return Value

array

$this setItemsPerPage(int $num)

No description

Parameters

int $num

Return Value

$this

int getItemsPerPage()

No description

Return Value

int

int getTotalRecords()

Get the total number of records in the list

Return Value

int

int getFirstShown()

Get the first shown record number

Return Value

int

$this setFirstShown(int $firstShown = 1)

Set the first shown record number. Will be stored in the state.

Parameters

int $firstShown

Return Value

$this

int getLastShown()

Get the last shown record number

Return Value

int

int getTotalPages()

Get the total number of pages, given the current number of items per page. The total pages might be higher than / if the first shown record is half way through a standard page break point.

Return Value

int

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.

Return Value

int

int getNextPage()

Get the next page number

Return Value

int

int getPreviousPage()

Get the previous page number

Return Value

int

$this setPageSizes(array $pageSizes)

Set the page sizes to use in the "Show x" dropdown

Parameters

array $pageSizes

Return Value

$this

array getPageSizes()

Get the sizes for the "Show x" dropdown

Return Value

array

ArrayList getPageSizesAsList()

Gets a list of page sizes for use in templates as a dropdown

Return Value

ArrayList

GridField getGridField()

Get the GridField used in this request

Return Value

GridField

Exceptions

Exception

$this setGridField(GridField $gridField)

Set the GridField so it can be used in other parts of the component during this request

Parameters

GridField $gridField

Return Value

$this

protected array getPagerArguments()

Returns an array containing the arguments for the pagination: total rows, pages, first record etc

Return Value

array

GridField_FormAction[] getPagerActions(array $controls, GridField $gridField)

Returns FormActions for each of the pagination actions, in an array

Parameters

array $controls
GridField $gridField

Return Value

GridField_FormAction[]