PHP Class GridFieldOrderableRows, silverstripe-gridfieldextensions

If the grid field has not been sorted, this component will sort the data by the sort field.
Inheritance: extends RequestHandler, implements GridField_ColumnProvider, implements GridField_DataManipulator, implements GridField_HTMLProvider, implements GridField_URLHandler
Mostrar archivo Open project: ajshort/silverstripe-gridfieldextensions Class Usage Examples

Protected Properties

Property Type Description
$extraSortFields string | array Extra sort fields to apply before the sort field.
$immediateUpdate boolean If set to true, when an item is re-ordered, it will update on the database and refresh the gridfield. When set to false, it will only update the sort order when the record is saved.
$reorderColumnNumber integer The number of the column containing the reorder handles
$sortField string The database field which specifies the sort, defaults to "Sort".

Public Methods

Method Description
__construct ( string $sortField = 'Sort' )
augmentColumns ( $grid, &$cols )
getColumnAttributes ( $grid, $record, $col )
getColumnContent ( $grid, $record, $col )
getColumnMetadata ( $grid, $col )
getColumnsHandled ( $grid )
getExtraSortFields ( ) : string | array
getHTMLFragments ( GridField $field )
getImmediateUpdate ( ) : boolean
getManipulatedData ( GridField $grid, SS_List $list )
getReorderColumnNumber ( ) : integer
getSortField ( ) : string
getSortTable ( SS_List $list ) : string Gets the table which contains the sort field.
getURLHandlers ( $grid )
handleMoveToPage ( GridField $grid, $request ) Handles requests to move an item to the previous or next page.
handleReorder ( GridField $grid, SS_HTTPRequest $request ) : SS_HTTPResponse Handles requests to reorder a set of IDs in a specific order.
handleSave ( GridField $grid, DataObjectInterface $record ) Handle saving when 'immediateUpdate' is disabled, otherwise this isn't necessary for the default sort mode.
setExtraSortFields ( string | array $fields ) : GridFieldOrderableRows Sets extra sort fields to apply before the sort field.
setImmediateUpdate ( $bool ) : GridFieldOrderableRows
setReorderColumnNumber ( integer $colno ) : GridFieldOrderableRows Sets the number of the column containing the reorder handles.
setSortField ( $field ) : GridFieldOrderableRows Sets the field used to specify the sort.

Protected Methods

Method Description
executeReorder ( GridField $grid, array $sortedIDs ) : boolean
getSortTableClauseForIds ( DataList $list, $ids )
getSortedIDs ( array $data ) : array Get mapping of sort value to ID from posted data
populateSortValues ( DataList $list )
reorderItems ( $list, array $values, array $sortedIDs )

Method Details

__construct() public method

public __construct ( string $sortField = 'Sort' )
$sortField string

augmentColumns() public method

public augmentColumns ( $grid, &$cols )

executeReorder() protected method

protected executeReorder ( GridField $grid, array $sortedIDs ) : boolean
$grid GridField
$sortedIDs array List of IDS, where the key is the sort field value to save
return boolean

getColumnAttributes() public method

public getColumnAttributes ( $grid, $record, $col )

getColumnContent() public method

public getColumnContent ( $grid, $record, $col )

getColumnMetadata() public method

public getColumnMetadata ( $grid, $col )

getColumnsHandled() public method

public getColumnsHandled ( $grid )

getExtraSortFields() public method

public getExtraSortFields ( ) : string | array
return string | array

getHTMLFragments() public method

public getHTMLFragments ( GridField $field )
$field GridField

getImmediateUpdate() public method

public getImmediateUpdate ( ) : boolean
return boolean

getManipulatedData() public method

public getManipulatedData ( GridField $grid, SS_List $list )
$grid GridField
$list SS_List

getReorderColumnNumber() public method

public getReorderColumnNumber ( ) : integer
return integer

getSortField() public method

public getSortField ( ) : string
return string

getSortTable() public method

Gets the table which contains the sort field.
public getSortTable ( SS_List $list ) : string
$list SS_List
return string

getSortTableClauseForIds() protected method

protected getSortTableClauseForIds ( DataList $list, $ids )
$list DataList

getSortedIDs() protected method

Get mapping of sort value to ID from posted data
protected getSortedIDs ( array $data ) : array
$data array Raw posted data
return array

getURLHandlers() public method

public getURLHandlers ( $grid )

handleMoveToPage() public method

Handles requests to move an item to the previous or next page.
public handleMoveToPage ( GridField $grid, $request )
$grid GridField

handleReorder() public method

Handles requests to reorder a set of IDs in a specific order.
public handleReorder ( GridField $grid, SS_HTTPRequest $request ) : SS_HTTPResponse
$grid GridField
$request SS_HTTPRequest
return SS_HTTPResponse

handleSave() public method

Handle saving when 'immediateUpdate' is disabled, otherwise this isn't necessary for the default sort mode.
public handleSave ( GridField $grid, DataObjectInterface $record )
$grid GridField
$record DataObjectInterface

populateSortValues() protected method

protected populateSortValues ( DataList $list )
$list DataList

reorderItems() protected method

protected reorderItems ( $list, array $values, array $sortedIDs )
$values array
$sortedIDs array

setExtraSortFields() public method

Sets extra sort fields to apply before the sort field.
public setExtraSortFields ( string | array $fields ) : GridFieldOrderableRows
$fields string | array
return GridFieldOrderableRows $this

setImmediateUpdate() public method

public setImmediateUpdate ( $bool ) : GridFieldOrderableRows
return GridFieldOrderableRows $this

setReorderColumnNumber() public method

Sets the number of the column containing the reorder handles.
public setReorderColumnNumber ( integer $colno ) : GridFieldOrderableRows
$colno integer
return GridFieldOrderableRows $this

setSortField() public method

Sets the field used to specify the sort.
public setSortField ( $field ) : GridFieldOrderableRows
return GridFieldOrderableRows $this

Property Details

$extraSortFields protected_oe property

Extra sort fields to apply before the sort field.
See also: setExtraSortFields()
protected string|array $extraSortFields
return string | array

$immediateUpdate protected_oe property

If set to true, when an item is re-ordered, it will update on the database and refresh the gridfield. When set to false, it will only update the sort order when the record is saved.
protected bool $immediateUpdate
return boolean

$reorderColumnNumber protected_oe property

The number of the column containing the reorder handles
See also: setReorderColumnNumber()
protected int $reorderColumnNumber
return integer

$sortField protected_oe property

The database field which specifies the sort, defaults to "Sort".
See also: setSortField()
protected string $sortField
return string