class GridFieldDropdownFilter implements GridField_HTMLProvider, GridField_ActionProvider, GridField_DataManipulator (View source)

GridFieldDropdownFilter provides a dropdown that can be used to filter a GridField arbitrarily

Constants

DEFAULT_OPTION_VALUE

Default string used in the value http attribute on the option for all results

Properties

protected string $name
protected string $targetFragment
protected SS_List $filterOptions
protected string $defaultOption

Methods

public
__construct(string $name, string $targetFragment, string $defaultOption = null)

No description

public
$this
addFilterOption(string $name, string $title, callable|array $filter)

Add an option to the dropdown that provides a filter

public
$this
removeFilterOption(string $name)

Remove a filter option with the given name

public
array
getActions($gridField)

Return a list of the actions handled by this action provider.

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

Handle an action on the given GridField.

public
getManipulatedData(GridField $gridField, SS_List $dataList)

Manipulate the DataList as needed by this grid modifier.

public
array
getHTMLFragments($gridField)

Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.

Details

__construct(string $name, string $targetFragment, string $defaultOption = null)

No description

Parameters

string $name

A name unique to this GridFieldDropdownFilter on this GridField

string $targetFragment

Fragment to write the html fragment to.

string $defaultOption

A string used as the label for the default "All results" option

$this addFilterOption(string $name, string $title, callable|array $filter)

Add an option to the dropdown that provides a filter

Parameters

string $name
string $title
callable|array $filter

Either a closure to filter a given SS_Filterable or a simple associative array will be used for filtering

Return Value

$this

$this removeFilterOption(string $name)

Remove a filter option with the given name

Parameters

string $name

Return Value

$this

array getActions($gridField)

Return a list of the actions handled by this action provider.

Used to identify the action later on through the $actionName parameter in handleAction.

There is no namespacing on these actions, so you need to ensure that they don't conflict with other components.

Parameters

$gridField

Return Value

array

with action identifier strings.

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

Handle an action on the given GridField.

Calls ALL components for every action handled, so the component needs to ensure it only accepts actions it is actually supposed to handle.

Parameters

GridField $gridField
$actionName
$arguments
$data

DataList getManipulatedData(GridField $gridField, SS_List $dataList)

Manipulate the DataList as needed by this grid modifier.

Parameters

GridField $gridField
SS_List $dataList

Return Value

DataList

array getHTMLFragments($gridField)

Returns a map where the keys are fragment names and the values are pieces of HTML to add to these fragments.

Here are 4 built-in fragments: 'header', 'footer', 'before', and 'after', but components may also specify fragments of their own.

To specify a new fragment, specify a new fragment by including the text "$DefineFragment(fragmentname)" in the HTML that you return.

Fragment names should only contain alphanumerics, -, and _.

If you attempt to return HTML for a fragment that doesn't exist, an exception will be thrown when the GridField is rendered.

Parameters

$gridField

Return Value

array