class GridFieldExportButton extends AbstractGridFieldComponent implements GridField_HTMLProvider, GridField_ActionProvider, GridField_URLHandler (View source)

Adds an "Export list" button to the bottom of a {@link GridField}.

Traits

A class that can be instantiated or replaced via DI

Properties

static private bool $xls_export_disabled

Set to true to disable XLS sanitisation [SS-2017-007] Ensure all cells with leading [@=+] have a leading tab

Methods

static Injectable
create(mixed ...$args)

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

static Injectable
singleton(string $class = null)

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

__construct(string $targetFragment = "after", array $exportColumns = null)

No description

array
getHTMLFragments(GridField $gridField)

Place the export button in a

tag below the field

array
getActions(GridField $gridField)

export is an action button

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

Handle an action on the given {@link GridField}.

array
getURLHandlers(GridField $gridField)

it is also a URL

handleExport(GridField $gridField, HTTPRequest $request = null)

Handle the export, for both the action button and the URL

string
generateExportFileData(GridField $gridField)

Generate export fields for CSV.

array
getExportColumns()

No description

$this
setExportColumns(array $cols)

No description

string
getCsvSeparator()

No description

$this
setCsvSeparator(string $separator)

No description

string
getCsvEnclosure()

No description

$this
setCsvEnclosure(string $enclosure)

No description

bool
getCsvHasHeader()

No description

$this
setCsvHasHeader(bool $bool)

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

__construct(string $targetFragment = "after", array $exportColumns = null)

Parameters

string $targetFragment

The HTML fragment to write the button into

array $exportColumns

The columns to include in the export

array getHTMLFragments(GridField $gridField)

Place the export button in a

tag below the field

Parameters

GridField $gridField

Return Value

array

array getActions(GridField $gridField)

export is an action button

Parameters

GridField $gridField

Return Value

array

with action identifier strings.

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

Handle an action on the given {@link 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
string $actionName

Action identifier, see {@link getActions()}.

array $arguments

Arguments relevant for this

array $data

All form data

array getURLHandlers(GridField $gridField)

it is also a URL

Parameters

GridField $gridField

Return Value

array

HTTPResponse handleExport(GridField $gridField, HTTPRequest $request = null)

Handle the export, for both the action button and the URL

Parameters

GridField $gridField
HTTPRequest $request

Return Value

HTTPResponse

string generateExportFileData(GridField $gridField)

Generate export fields for CSV.

Parameters

GridField $gridField

Return Value

string

array getExportColumns()

Return Value

array

$this setExportColumns(array $cols)

Parameters

array $cols

Return Value

$this

string getCsvSeparator()

Return Value

string

$this setCsvSeparator(string $separator)

Parameters

string $separator

Return Value

$this

string getCsvEnclosure()

Return Value

string

$this setCsvEnclosure(string $enclosure)

Parameters

string $enclosure

Return Value

$this

bool getCsvHasHeader()

Return Value

bool

$this setCsvHasHeader(bool $bool)

Parameters

bool $bool

Return Value

$this