panel.dataTable
Description
Creates a <table> element using data retrieved via REST. The data returned from the REST call needs to be an array of objects
Spawner Widget Name
kind: panel.dataTable
JavaScript Method
XNAT.ui.panel.dataTable()
Configuration Options
dataTable:
kind: panel.dataTable
name: fooTable
label: Ur Data
load: /data/path
[data]: [
{ id: 1, firstname: 'Carl', lastname: 'Carlson', username: 'ccarlson', website: 'carl-carlson.name' },
{ id: 2, firstname: 'Lenny', lastname: 'Leonard', username: 'lennyl', website: 'leonnyard.org' },
{ id: 3, firstname: 'Bob', lastname: 'Robertson', username: 'brobertson', website: 'bobertson.net' }
]
[path]: "object.path.to.data"
[header]: true
[items]:
id: ~!
firstname: First Name
lastname: Last Name
username: Username
website:
label: Website
content: <a href="__VALUE__">Website</a>
[id]: foo-table
[dataType]: json
[sortable]: true -or- "list, of, sortable, columns"
[container]: "#parent-element"
[width]: 300px
[element]:
className: foo bar
title: "This is your data, and it's rendering one row at a time."
[before]: "Text, HTML, or Spawner object(s) to insert before the element."
[after]:
smallTxt:
tag: small.msg
content: "This small message has been brought to you by Spawner."
Properties
Name | Value | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
kind | panel.dataTable | Spawner widget type - creates a <table> element that loads data from a url or specific data set in data property. | ||||||||||||||||||||||||
name | (string) | Name attribute for this input, which must match the property name used for data loading and submission. | ||||||||||||||||||||||||
label | (string) | Label for table. | ||||||||||||||||||||||||
header | (boolean) | Should the property names of the first data object be used for the column headers? This does not affect output if there are items specified. | ||||||||||||||||||||||||
items | (string / object) | Object map of properties to include in the rendered table. The property name here must match the property name in the data object, and the value will be used as the label for the header <th> element. Properties with a value of "~!" will be hidden columns. The data will be in the table, but the associated <th> and <td> elements will be hidden. If an object is used for an item's value, the | ||||||||||||||||||||||||
items['name'] | (string / object) | For each 'item' property, if using a string, this will be the label for the column header. No other options can be set. For each 'item' property, if using a config object, the following can be set:
| ||||||||||||||||||||||||
id | (string) | Value for spawned element's id attribute. | ||||||||||||||||||||||||
load/url | (url) | REST URL to retrieve data | ||||||||||||||||||||||||
data | (array) | Explicitly pass data as an array of data objects or 2D array. | ||||||||||||||||||||||||
path | (string) | Custom path to use for looking up object data returned from url specified in the
CODE
| ||||||||||||||||||||||||
dataType | json | What kind of data will be returned from the request? JSON is supported and is the default - XML support is planned. | ||||||||||||||||||||||||
sortable | (boolean / comma-separated list) | Are the columns sortable? Enter true to make ALL columns sortable, or a comma-separated list of the columns that can be sorted. The column names must match the object property names from the returned data. | ||||||||||||||||||||||||
container | (string - selector) | Selects existing DOM element that this table will be appended to (inserted into). If the container property is used, the table will not be rendered in the usual Spawner manner - it will not show up as a child of a parent element if it's in the parent's contents . | ||||||||||||||||||||||||
width | (string - CSS width) | Explicitly set CSS 'width' property. Will default to '100% ' if not specified. | ||||||||||||||||||||||||
element | (object) | Object map of DOM attributes and properties to be directly attached to this table. Any attribute that can be added natively to a DOM element can be used in the element object. | ||||||||||||||||||||||||
before | (string / Spawner object) | HTML string or Spawner config object that will be inserted before this <table> element. | ||||||||||||||||||||||||
after | (string / Spawner object) | HTML string or Spawner config object that will be inserted after this <table> element. |