Column
extends Ext
in package
Column configuration object. This is used to define how a column should be read from a database table.
This class is largely a proxy to \DataTables\Editor\Field, exposing only
the read aspects of the class, and not being writable.
Table of Contents
Methods
- __construct() : mixed
- Field instance constructor.
- columnControl() : mixed
- Options for ColumnControl's searchList content type.
- dbField() : mixed
- Get / set the DB field name.
- getFormatter() : mixed
- Get formatter for the columns's data.
- getValue() : mixed
- Get / set a get value. If given, then this value is used to send to the client-side, regardless of what value is held by the database.
- inst() : static
- Static method to instantiate a new instance of a class (shorthand of 'instantiate').
- instantiate() : static
- Static method to instantiate a new instance of a class.
- name() : mixed
- Get / set the 'name' property of the field.
- searchBuilderOptions() : mixed
- Get a list of values that can be used for the options list in SearchBuilder.
- searchPaneOptions() : mixed
- Get a list of values that can be used for the options list in SearchPanes.
- _getSet() : mixed
- Common getter / setter function for DataTables classes.
- _propExists() : bool
- Determine if a property is available in a data set (allowing `null` to be a valid value).
- _proxy() : mixed
- Execute a method from a given instance. If the return is that instance, then return self instead, otherwise give the returned value.
- _readProp() : mixed
- Read a value from a data structure, using Javascript dotted object notation. This is the inverse of the `_writeProp` method and provides the same support, matching DataTables' ability to read nested JSON data objects.
- _writeProp() : mixed
- Write the field's value to an array structure, using Javascript dotted object notation to indicate JSON data structure. For example `name.first` gives the data structure: `name: { first: ... }`. This matches DataTables own ability to do this on the client-side, although this doesn't implement implement quite such a complex structure (no array / function support).
Methods
__construct()
Field instance constructor.
public
__construct([string $dbField = null ][, string $name = null ]) : mixed
Parameters
- $dbField : string = null
-
Name of the database column
- $name : string = null
-
Name to use in the JSON output from Editor and the HTTP submit from the client-side when editing. If not given then the $dbField name is used.
columnControl()
Options for ColumnControl's searchList content type.
public
columnControl([Options $_ = null ]) : mixed
Parameters
- $_ : Options = null
-
Options
dbField()
Get / set the DB field name.
public
dbField([string $_ = null ]) : mixed
Note that when used as a setter, an alias can be given for the field
using the SQL as keyword - for example: firstName as name. In this
situation the dbField is set to the field name before the as, and the
field's name (name()) is set to the name after the as.
As a result of this, the following constructs have identical functionality:
new Field( 'firstName as name' ); new Field( 'firstName', 'name' );
Parameters
- $_ : string = null
-
Value to set if using as a setter.
Return values
mixed —The name of the db field if no parameter is given.
getFormatter()
Get formatter for the columns's data.
public
getFormatter([callable(mixed, array<string|int, mixed>, array<string|int, mixed>): string $_ = null ][, mixed $opts = null ]) : mixed
When the data has been retrieved from the server, it can be passed through a formatter here, which will manipulate (format) the data as required. This can be useful when, for example, working with dates and a particular format is required on the client-side.
Parameters
- $_ : callable(mixed, array<string|int, mixed>, array<string|int, mixed>): string = null
-
Value to set if using as a setter. Can be given as a closure function or a string with a reference to a function that will be called with call_user_func().
- $opts : mixed = null
-
Variable that is passed through to the get formatting function - can be useful for passing through extra information such as date formatting string, or a required flag. The actual options available depend upon the formatter used.
Return values
mixed —The get formatter if no parameter is given.
getValue()
Get / set a get value. If given, then this value is used to send to the client-side, regardless of what value is held by the database.
public
getValue([callable(): mixed|string|number $_ = null ]) : mixed
Parameters
- $_ : callable(): mixed|string|number = null
-
Value to set, or no value to use as a getter
Return values
mixed —Value if used as a getter.
inst()
Static method to instantiate a new instance of a class (shorthand of 'instantiate').
public
static inst() : static
This method performs exactly the same actions as the 'instantiate' static method, but is simply shorter and easier to type!
Return values
static —class
instantiate()
Static method to instantiate a new instance of a class.
public
static instantiate() : static
A factory method that will create a new instance of the class that has extended 'Ext'. This allows classes to be instantiated and then chained - which otherwise isn't available until PHP 5.4. If using PHP 5.4 or later, simply create a 'new' instance of the target class and chain methods as normal.
Return values
static —Instantiated class
name()
Get / set the 'name' property of the field.
public
name([string $_ = null ]) : mixed
The name is typically the same as the dbField name, since it makes things less confusing(!), but it is possible to set a different name for the data which is used in the JSON returned to DataTables in a 'get' operation and the field name used in a 'set' operation.
Parameters
- $_ : string = null
-
Value to set if using as a setter.
Return values
mixed —The name property if no parameter is given.
searchBuilderOptions()
Get a list of values that can be used for the options list in SearchBuilder.
public
searchBuilderOptions([SearchBuilderOptions|callable(Database, Editor): Array $sbInput = null ]) : mixed
Parameters
- $sbInput : SearchBuilderOptions|callable(Database, Editor): Array = null
-
SearchBuilderOptions instance or a closure function if providing a method
searchPaneOptions()
Get a list of values that can be used for the options list in SearchPanes.
public
searchPaneOptions([SearchPaneOptions|callable(Database, Editor): Array $spInput = null ]) : mixed
Parameters
- $spInput : SearchPaneOptions|callable(Database, Editor): Array = null
-
SearchPaneOptions instance or a closure function if providing a method
_getSet()
Common getter / setter function for DataTables classes.
protected
_getSet(mixed &$prop, mixed $val[, bool $array = false ]) : mixed
This getter / setter method makes building getter / setting methods easier, by abstracting everything to a single function call.
Parameters
- $prop : mixed
-
The property to set
- $val : mixed
-
The value to set - if given as null, then we assume that the function is being used as a getter.
- $array : bool = false
-
Treat the target property as an array or not (default false). If used as an array, then values passed in are added to the $prop array.
_propExists()
Determine if a property is available in a data set (allowing `null` to be a valid value).
protected
_propExists(string $name, array<string|int, mixed> $data) : bool
Parameters
- $name : string
-
Javascript dotted object name to write to
- $data : array<string|int, mixed>
-
Data source array to read from
Return values
bool —true if present, false otherwise
_proxy()
Execute a method from a given instance. If the return is that instance, then return self instead, otherwise give the returned value.
protected
_proxy(mixed $inst, string $method, array<string|int, mixed> $args) : mixed
Parameters
- $inst : mixed
-
Class instance
- $method : string
-
Method to execute
- $args : array<string|int, mixed>
-
The arguments from the function
Return values
mixed —Value from the executed function or self.
_readProp()
Read a value from a data structure, using Javascript dotted object notation. This is the inverse of the `_writeProp` method and provides the same support, matching DataTables' ability to read nested JSON data objects.
protected
_readProp(string $name, array<string|int, mixed> $data) : mixed
Parameters
- $name : string
-
Javascript dotted object name to write to
- $data : array<string|int, mixed>
-
Data source array to read from
Return values
mixed —The read value, or null if no value found.
_writeProp()
Write the field's value to an array structure, using Javascript dotted object notation to indicate JSON data structure. For example `name.first` gives the data structure: `name: { first: ... }`. This matches DataTables own ability to do this on the client-side, although this doesn't implement implement quite such a complex structure (no array / function support).
protected
_writeProp(array<string|int, mixed> &$out, string $name, mixed $value) : mixed
Parameters
- $out : array<string|int, mixed>
-
Array to write the data to
- $name : string
-
Javascript dotted object name to write to
- $value : mixed
-
Value to write