DataTable
The component for adding a JSON data table.
Declaration
object DataTableProperties
| Name | Type | Description |
|---|---|---|
data Required | RecordStore | An object that provides data for the table. This property also provides information about the data, such as data types and header labels, in the form of the data descriptor. |
role Required | string | Always |
anchor | Anchor | An object that defines vertical alignment with another component. |
animation | (ComponentAnimation | string("none")) | An object that defines an animation to be applied to the component. The |
behavior | (Behavior | string("none")) | An object that defines behavior for a component, like Parallax or Springy. The |
conditional | (ConditionalComponent | [ConditionalComponent]) | An instance or array of component properties that can be applied conditionally, and the conditions that cause them to be applied. |
dataOrientation | string | A string value that determines the table orientation. Valid values:
|
hidden | boolean | A Boolean value that determines whether the component is hidden. |
identifier | string | An optional unique identifier for this component. If used, this |
layout | (ComponentLayout | string) | An inline If |
showDescriptorLabels | boolean | A Boolean value that determines whether the headers are shown. If |
sortBy | [DataTableSorting] | An array that determines how table data is sorted. Rules are applied in the order in which they are provided in the array. If this property is not defined, data records are displayed in the order in which they are provided in the data RecordStore. |
style | (ComponentStyle | string | string("none")) | An inline If this property is omitted, the table is styled according to a component style called The |
Mentioned in
Discussion
Add a DataTable component that uses table data provided in a JSON format. Information about the table, including the data itself, is provided by the data property, whose value is a RecordStore object that contains both the table data and information about the data, such as data types and header labels.
You can apply styles to table rows, columns, and cells using a ComponentStyle object that has a TableStyle defined.
Example
{
"components": [
{
"role": "datatable",
"showDescriptorLabels": true,
"sortBy": [
{
"descriptor": "id-name",
"direction": "descending"
}
],
"data": {
"descriptors": [
{
"identifier": "id-name",
"key": "name",
"label": {
"type": "formatted_text",
"text": "Name",
"textStyle": {
"textColor": "black"
}
},
"dataType": "string"
},
{
"identifier": "id-occupation",
"key": "occupation",
"label": "Occupation",
"dataType": "string"
}
],
"records": [
{
"name": "Amelia Earhart",
"occupation": "Pilot"
},
{
"name": "Grace Hopper",
"occupation": "Computer Scientist"
}
]
},
"style": {
"tableStyle": {
"rows": {
"backgroundColor": "#fff",
"divider": {
"width": 1,
"color": "#ddd"
}
},
"headerRows": {
"backgroundColor": "#ccc",
"divider": {
"width": 2,
"color": "#999"
}
},
"cells": {
"padding": 6,
"verticalAlignment": "top"
}
}
},
"layout": {
"columnStart": 0,
"columnSpan": 7,
"margin": 20
}
}
]
}