Class SearchPaneOptions
The Options class provides a convenient method of specifying where Editor
should get the list of options for a select
, radio
or checkbox
field.
This is normally from a table that is left joined to the main table being
edited, and a list of the values available from the joined table is shown to
the end user to let them select from.
Options
instances are used with the Field::options method.
-
DataTables\Ext
-
DataTables\Editor\SearchPaneOptions
Namespace: DataTables\
Editor
Example:
Get a list of options from the sites
table
Field::inst( 'users.site' )
->options( Options::inst()
->table( 'sites' )
->value( 'id' )
->label( 'name' )
)
Example:
Get a list of options with custom ordering
Field::inst( 'users.site' )
->options( Options::inst()
->table( 'sites' )
->value( 'id' )
->label( 'name' )
->order( 'name DESC' )
)
Example:
Get a list of options showing the id and name in the label
Field::inst( 'users.site' )
->options( Options::inst()
->table( 'sites' )
->value( 'id' )
->label( [ 'name', 'id' ] )
->render( function ( $row ) {
return $row['name'].' ('.$row['id'].')';
} )
)
Located at Editor/SearchPaneOptions.php
Methods summary
public
DataTables\Editor\Options |string[]
|
#
label( null|string|string[] $_ = null )
Get / set the column(s) to use as the label value of the options
Get / set the column(s) to use as the label value of the options
Parameters
- $_
null to get the current value, string or
array to get.
Returns
|
public
DataTables\Editor\Options |string
|
#
order( null|string $_ = null )
Get / set the ORDER BY clause to use in the SQL. If this option is not
provided the ordering will be based on the rendered output, either
numerically or alphabetically based on the data returned by the renderer.
Get / set the ORDER BY clause to use in the SQL. If this option is not
provided the ordering will be based on the rendered output, either
numerically or alphabetically based on the data returned by the renderer.
Parameters
- $_
- String to set, null to get current value
Returns
|
public
DataTables\Editor\Options |callable
|
#
render( null|callable $_ = null )
Get / set the label renderer. The renderer can be used to combine
multiple database columns into a single string that is shown as the label
to the end user in the list of options.
Get / set the label renderer. The renderer can be used to combine
multiple database columns into a single string that is shown as the label
to the end user in the list of options.
Parameters
- $_
- Function to set, null to get current value
Returns
|
public
DataTables\Editor\Options |string
|
#
table( null|string $_ = null )
Get / set the database table from which to gather the options for the
list.
Get / set the database table from which to gather the options for the
list.
Parameters
- $_
- String to set, null to get current value
Returns
|
public
DataTables\Editor\Options |string
|
#
value( null|string $_ = null )
Get / set the column name to use for the value in the options list. This
would normally be the primary key for the table.
Get / set the column name to use for the value in the options list. This
would normally be the primary key for the table.
Parameters
- $_
- String to set, null to get current value
Returns
|
public
DataTables\Editor\Options |callable
|
#
where( null|callable $_ = null )
Get / set the method to use for a WHERE condition if it is to be
applied to the query to get the options.
Get / set the method to use for a WHERE condition if it is to be
applied to the query to get the options.
Parameters
- $_
- Function to set, null to get current value
Returns
|
public
DataTables\Editor\SearchPaneOptions
|
#
leftJoin( string $table, string $field1, string $operator, string $field2 )
Get / set the array values used for a leftJoin condition if it is to be
applied to the query to get the options.
Get / set the array values used for a leftJoin condition if it is to be
applied to the query to get the options.
Parameters
- $table
- to get the information from
- $field1
- the first field to get the information from
- $operator
- the operation to perform on the two fields
- $field2
- the second field to get the information from
Returns
|