Tables can easily be created and manipulated in scripts.
The Table structure is relatively simple to create, read and modify.
The Table Script (library.table.TableScript) script defines a Table object which can be used to create and display tables – see the script for details of the API. The Table Script supports creation of tables from strings, loaded from nodes, dynamic tables, building tables from nodes and views, and provides the render() method used to display tables. When using the Table Script, remember that it wraps the underlying table structure in an object, and you need to use the getTable() method to access the underlying table structure.
Tables can be converted to strings using the application.stringify() method. If they are written to members, they can be retrieved using the Table Script Table.load() method.
A number of scripts extend the base Table Script to provide table-level functions.
- The Table Filter Script (library.table.TableFilterScript) extends the table script to provide a filter() method. This creates a new table by selecting rows and columns from the old table, like an SQL select clause.
- The Table Merge Script (library.table.TableMergeScript) extends the table script to provide a merge() method. This merges another table into the table, like an SQL JOIN or UNION.
- The Table Aggregator Script (library.table.TableAggregatorScript) extends the table script to provide an aggregate() method. This creates a new table by performing aggregation functions over the old table. The aggregation uses grouping and pivot operations, and suppots count, sum, avg, min, max and array functions.
See the script documentation for details.
Script table types
The Script Table (library.table.ScriptTableType), Script Table Type (library.table.ScriptTableTypeType) and Script Table Member Type (library.table.ScriptTableMemberTypeType) types allow tables to be built using scripts. These do not have to use Table Script, but often do, particularly to read table data from other nodes.
The Flexi Table Script (library.table.FlexiTableScript) is an advanced table-handling component for viewing the nodes in a package. It allows the user to:
- Select which nodes to view, based on their tags.
- Select which type of view, such as "tabular" or "summary". This is known as a view family.
- Within the view family, have the flexitable select an appropriate view for the type of data.
- Select options within the view family, such as number of columns.
Flexitables remember which views a user has selected, and cache different views so that users get fast page displays.
Flexitables are recommended for advanced developers only. In most cases, flexitables can be applied by reusing the member types from Package.