class GridFieldPaginator extends AbstractGridFieldComponent implements GridField_HTMLProvider, GridField_DataManipulator, GridField_ActionProvider, GridField_StateProvider (View source)

GridFieldPaginator paginates the GridField list and adds controls to the bottom of the GridField.

Traits

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

Properties

protected int $itemsPerPage
protected $throwExceptionOnBadDataType

See setThrowExceptionOnBadDataType()

protected $totalItems

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
stat(string $name) deprecated

Get inherited config value

public
mixed
uninherited(string $name)

Gets the uninherited value for the given config option

public
$this
set_stat(string $name, mixed $value) deprecated

Update the config value for a given property

public
__construct(int $itemsPerPage = null)

No description

public
$this
setThrowExceptionOnBadDataType(bool $throwExceptionOnBadDataType)

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

public
bool
getThrowExceptionOnBadDataType()

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)

Retrieves/Sets up the state object used to store and retrieve information about the current paging details of this GridField

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)

Determines arguments to be passed to the template for building this field

public
array
getHTMLFragments(GridField $gridField)

No description

public
$this
setItemsPerPage(int $num)

No description

public
int
getItemsPerPage()

No description

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 stat(string $name) deprecated

deprecated 5.0 Use ->config()->get() instead

Get inherited config value

Parameters

string $name

Return Value

mixed

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

$this set_stat(string $name, mixed $value) deprecated

deprecated 5.0 Use ->config()->set() instead

Update the config value for a given property

Parameters

string $name
mixed $value

Return Value

$this

__construct(int $itemsPerPage = null)

No description

Parameters

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

$this setThrowExceptionOnBadDataType(bool $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

bool $throwExceptionOnBadDataType

Return Value

$this

bool getThrowExceptionOnBadDataType()

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)

Retrieves/Sets up the state object used to store and retrieve information about the current paging details of this GridField

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)

Determines arguments to be passed to the template for building this field

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