The table
field.
The table field is useful when you have an array of data objects that have a uniform structure. It provides a condensed and table-based way of viewing data. In editable mode, each table field has a toolbar at the top for adding new rows. Each row in the table has an action bar.
The table field is an extension of the ArrayField and so all array field configuration options apply.
Title | Table Field |
Description | Renders array items into a table |
JSON Schema Type(s) | array |
Field Type | table |
Base Field Type | array |
Property | Type | Default | Description |
---|---|---|---|
default | any | The default value to be assigned for this property. If the data for the field is empty or not provided, this default value will be plugged in for you. Specify a default value when you want to pre-populate the field's value ahead of time. | |
dependencies | array | List of property dependencies. | |
description | string | Detailed description of the property. | |
disallow | array | List of disallowed values for the property. | |
format | string | Data format of the property. | |
items | object | Schema for array items. | |
maxItems | number | Maximum number of items. | |
minItems | number | Minimum number of items. | |
readonly | boolean | Indicates that the field is read-only. A read-only field cannot have it's value changed. Read-only fields render in a grayed-out or disabled control. If the field is rendered using a view with the displayReadonly attribute set to false, the read-only field will not appear. | |
required | boolean | Indicates whether the field's value is required. If set to true, the field must take on a valid value and cannnot be left empty or unassigned. | |
title | string | Short description of the property. | |
type | string | array | Data type of the property. |
uniqueItems | boolean | Item values should be unique if true. |
Property | Type | Default | Description |
---|---|---|---|
actionbar | object | ||
actionbarStyle | string | top | The kind of actionbar to render for each item in the array. Either 'top', 'bottom', 'left', or 'right'. |
animate | boolean | true | Up and down transitions will be animated |
collapsed | boolean | Field set is initially collapsed if true. | |
collapsible | boolean | Field set is collapsible if true. | |
datatables | object | Optional configuration to be passed to the underlying DataTables Plugin. | |
disabled | boolean | Field will be disabled if true. | |
dragAndDrop | boolean | If true, drag and drop is enabled for array items. | |
dragRows | boolean | Whether to enable the dragging of rows via a draggable column. This requires DataTables and the DataTables Row Reorder Plugin. | |
fieldClass | string | Specifies one or more CSS classes that should be applied to the dom element for this field once it is rendered. Supports a single value, comma-delimited values, space-delimited values or values passed in as an array. | |
focus | checkbox | true | If true, the initial focus for the form will be set to the first child element (usually the first field in the form). If a field name or path is provided, then the specified child field will receive focus. For example, you might set focus to 'name' (selecting the 'name' field) or you might set it to 'client/name' which picks the 'name' field on the 'client' object. |
form | object | Options for rendering the FORM tag. | |
helper | string | Field help message. | |
helpers | array | An array of field help messages. Each message will be displayed on it's own line. | |
helpersPosition | string | below | Defines the placement location of the helper text relative to the control (either 'above' or 'below') |
hidden | boolean | Field will be hidden if true. | |
hideInitValidationError | boolean | Hide initial validation errors if true. | |
hideToolbarWithChildren | boolean | true | Indicates whether to hide the top toolbar when child elements are available. |
id | string | Unique field id. Auto-generated if not provided. | |
label | string | Field label. | |
lazyLoading | boolean | Child fields will only be rendered when the fieldset is expanded if this option is set true. | |
legendStyle | string | button | Field set legend style. |
optionLabels | array | An array of string labels for items in the enum array | |
readonly | boolean | Field will be readonly if true. | |
showActionsColumn | boolean | true | Whether to show or hide the actions column. |
showMessages | boolean | true | Display validation messages if true. |
toolbar | object | ||
toolbarPosition | string | top | Location of the top-level toolbar to render for the array field. Either 'top' or 'bottom'. |
toolbarSticky | boolean | If true, the array item toolbar will always be enabled. If false, the toolbar is always disabled. If undefined or null, the toolbar will appear when hovered over. | |
toolbarStyle | string | button | The kind of top-level toolbar to render for the array field. Either 'button' or 'link'. |
type | string | table | Field type. |
validate | boolean | true | Field validation is required if true. |
view | string | Allows for this field to be rendered with a different view (such as 'display' or 'create') |
Table field for an array of text items.
Here is a more advanced table with a few additional control types. We wrap the form with a button that hands back the underlying JSON.
Here is a table with the data shown in display mode. When in display mode, the table does not show it's actions or toolbar buttons.
Here is a table with the data shown in read-only. When in read-only mode, the table does not show it's actions or toolbar buttons.
The table field uses the esteemed Data Tables Plugin,
if available, to format the table and provide additional interaction features. You can use the
options.datatables
field to pass configuration information to the underlying Data Tables Plugin.
You can also set options.datatables
to false to disable the Plugin.
You can disable the actions column by setting showActionsColumn
to false.
Mix table with interesting control types for inline editing. Here, we maintain a rank
property that
auto-updates as fields move around. The "Show JSON" button in the form lets us see the resulting JSON for the table.
Adding and removing rows dynamically using setValue.
Drag-and-drop support for draggable table row re-ordering using the dragRows
option.
Set dragRows
to true
to enable draggable rows within your table.
NOTE: This feature currently requires the datatables.net-rowreorder
plugin as well as the core datatables.net
library.
See the DataTables RowReorder Plugin for more information.
If you run into problems with the placement of the draggable overlay, you may need to force absolute positioning of the overlay like this:
.table.dt-rowReorder-float
{
position: absolute !important;
}
NOTE: This feature is experimental and may change in the future. We're not altogether that happy with the
DataTables RowReorder Plugin and may seek to implement differently. However, the dragRows
option will
continue to work as it does currently and will be supported in the future.