Description
Render data as a table in various formats: HTML (default), CSV, or XLSX.
Comments
When rendered as HTML in the browser, the columns of the table can be optionally made sortable.
Examples
[%$columns = [
"Last name",
"First name",
["name" => "Date of birth", "datatype" => "date", "format" => "format_date"]
];
echo table(rows: $rows, columns: $columns, sortable: true, sort: "1"); %]
[%content_type("csv");
echo table($rows, format: "csv"); %]
|
Parameters10
Coding name |
rows
|
Description |
An array holding of stdClass objects (= a hash map in object form).
|
Position |
2
|
Type |
Array(Primitive type)
|
Coding name |
columns
|
Description |
An array of strings, the column names. If datatype or format needs to be specified, an stdClass object with a mandatory name and optionally datatype, format, sortable.
|
Position |
3
|
Type |
Array(Primitive type)
|
Coding name |
format
|
Description |
The format of the table. Either html, xlsx or csv.
|
Position |
4
|
Type |
String(Primitive type)
|
Default value |
html
|
Coding name |
empty
|
Description |
A simple string, if the table has zero rows.
|
Position |
5
|
Type |
String(Primitive type)
|
Default value |
The empty string.
|
Coding name |
style
|
Description |
The table style. Currently there is only one supported table style called 'tom'.
|
Position |
6
|
Type |
String(Primitive type)
|
Default value |
tom
|
Coding name |
striped
|
Description |
Whether the table should be striped.
|
Position |
7
|
Type |
|
Default value |
0, the table is not striped.
|
Comments |
- * 0, false: the table is not striped.
* 1, true: odd lines are highlighted.
* 2: even lines are highlighted.
- Only supported with format %html%.
|
Coding name |
sort
|
Description |
The index of the column the table is sorted by. This will mark the arrows in the header accordingly.
|
Position |
8
|
Type |
|
Default value |
null. None of columns will be initially marked sorted in the header.
|
Comments |
- Put a minus in front of an index to mark the upwards arrow.
- If there is more than one column sorted, use SPACE to separate the indices, e.g. "-2 1".
|
Coding name |
sortable
|
Description |
Whether the table is sortable. If false, individual columns can be declared sortable.
|
Position |
9
|
Type |
|
Default value |
false. The table is not sortable.
|
Coding name |
id
|
Description |
The id of the table.
|
Position |
10
|
Type |
|
Comments |
Only supported if format is %html%.
|
|