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.

Properties

protected int $itemsPerPage from  GridFieldPaginator
protected string $itemClass

Which template to use for rendering

protected $throwExceptionOnBadDataType

See setThrowExceptionOnBadDataType()

from  GridFieldPaginator
protected $totalItems from  GridFieldPaginator
protected GridField $gridField
protected GridState_Data $gridFieldState
protected int[] $pageSizes

Methods

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

No description

public
setThrowExceptionOnBadDataType($throwExceptionOnBadDataType)

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

public
getThrowExceptionOnBadDataType()

See setThrowExceptionOnBadDataType()

protected
checkDataType($dataList)

Check that this dataList is of the right data type.

public
array
getActions($gridField)

No description

public
handleAction(GridField $gridField, $actionName, $arguments, $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
getManipulatedData(GridField $gridField, SS_List $dataList)

No description

public
ArrayData|null
getTemplateParameters(GridField $gridField)

Add the configurable page size options to the template data

public
array
getHTMLFragments($gridField)

No description

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

__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

setThrowExceptionOnBadDataType($throwExceptionOnBadDataType)

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

$throwExceptionOnBadDataType

getThrowExceptionOnBadDataType()

See setThrowExceptionOnBadDataType()

protected checkDataType($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

$dataList

array getActions($gridField)

No description

Parameters

$gridField

Return Value

array

with action identifier strings.

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

No description

Parameters

GridField $gridField
$actionName
$arguments
$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

DataList getManipulatedData(GridField $gridField, SS_List $dataList)

No description

Parameters

GridField $gridField
SS_List $dataList

Return Value

DataList

ArrayData|null getTemplateParameters(GridField $gridField)

Add the configurable page size options to the template data

{@inheritDoc}

Parameters

GridField $gridField

Return Value

ArrayData|null

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)

No description

Parameters

$gridField

Return Value

array

setItemsPerPage($num)

No description

Parameters

$num

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[]