Aside form the regular storage modes, tabledata can also work with m:n relation-type data:
If you have an object connected to multiple objects of another class via an extended
mapping table, the mapping table entries can be displayed as rows.
Example: If a customer in a web shop orders a few items from the catalog, his order
will likely be placed in a mapping table which contains the ordered amount and other data
and links to the user object and the respective product object.
This code adds a widget to an edit account form which displays the ordered items as
rows and the order information (quantity and so on) as columns:
'orders' => Array
(
'title' => 'My Orders',
'description' => '',
'helptext' => '',
'type_config' => Array
(
'print_row_names' => true,
'sortable_columns' => false,
'sortable_rows' => false,
'storage_mode' => 'link',
'link_class' => 'orders_dba',
'link_parent_field' => 'user',
'link_parent_type' => 'id',
'link_columns' => Array('quantity', 'shipping', 'notes'),
'link_row_property' => 'product',
'link_row_class' => 'product_dba',
'link_row_title_field' => 'product_title',
),
'type' => 'tabledata',
'widget' => 'tabledata',
),
Methods
_on_initialize ()
Add JavaScript files if requested
Returns
boolean
Indicating success
convert_from_csv ($source)
convert_from_storage (String $source)
Convert the data from storage
Parameters
$source
String
source
convert_to_html ()
HTML output
Returns
String
Output string
convert_to_storage ()
Convert the data to storage
get_existing_columns ()
Get the existing columns in the correct order
Returns
Array
containing column details as key => name pairs
get_existing_rows ()
Get the existing rows.
Returns
Array
containing row information
get_row (String $row)
Get row by its ID
Parameters
$row
String
Row identifier
Returns
mixed
Array containing columns and values as key => value pairs or false on failure
get_table_data ()
Get the whole table
Returns
Array
containing values
get_value (String $row, String $column)
Get the value of a single cell
Parameters
$row
String
Row name
$column
String
Column name
Properties
Array $_column_order
Column sort order
Array $_original_columns
Safety for the original columns
Array $_remove_columns
List of columns that shall be removed
Array $_row_order
Row sort order
Array $_storage_data
Storage data or the data that should be stored
boolean $allow_column_rename
Should the column renaming be enabled
boolean $allow_new_columns
Should adding new columns be allowed?
boolean $allow_new_rows
Allow creation of new rows
integer $column_limit
Maximum number of columns
Array $columns
Column header data
String $link_class
DBA class of the link object
for storage_mode link only
Array $link_columns
Link fields that should be displayed as columns
for storage_mode link only
String $link_parent_field
The property of the link object which links to the current object
for storage_mode link only
String $link_parent_type
Is the object connected to the link via GUID or ID
for storage_mode link only
Array $link_row_class
The classname of the object used for rows
for storage_mode link only
Array $link_row_property
The link field that should be displayed as the row title
for storage_mode link only
Array $link_row_title_field
The title property of the object used for rows
for storage_mode link only
String $parameter_domain
Parameter domain that will be used to store the data
boolean $print_row_names
Should the row names be printed?
String $row_limit
Maximum amount of rows
String $row_sort_order
Row sort order
Array $rows
Row header data
boolean $sortable_columns
Allow sorting of the columns
boolean $sortable_rows
Allow sorting of the rows
String $storage_mode
Storage mode determines how the information is stored
String $storage_mode_parameter_limiter
Storage mode 'parameter' limiter
integer $_row_count
How many rows have been printed