"records" Macro
Reference
Description
XWiki 18.10.0+ Displays the entries of an object type, the Objects of one Class, as a Live Data table that readers can sort and filter, and edit if the author allows it.
The Macro is a block Macro and takes no content.
Usage
Only class is mandatory. Without properties, the table displays the title of the entries followed by every field of the object type:
{{records
class="..."
properties="..."
filters="..."
sort="..."
/}}The properties, filters and sort parameters take the same values as their "liveData" Macro counterparts. When a parameter names something the table cannot use, a warning above the table says so:
| Problem | What the table does |
|---|---|
| A field no longer exists in the object type | Skips the column, the filter or the sort on it. |
| A field cannot be filtered or sorted on | Ignores the filter, or the sort on it; the warning says what the table is sorted on instead. |
| A filter value does not fit the type of its field, or a filter cannot be read | Ignores the filter. |
| The creation strategy is not installed, or needs a column the table does not display | Does not let readers add entries. |
| The object type no longer exists | Displays an error instead of the table, and leaves the Macro call unchanged. |
Parameters
| Name | Mandatory | Allowed Values | Default Value | Description |
|---|---|---|---|---|
| class | Yes | The reference of a Class Page | N/A | "Object type": the Class whose Objects are listed. |
| properties | No | A comma-separated list of field names and page metadata, such as doc.title or doc.date | The title, then every field of the object type | "Columns": the columns to display, in order. |
| filters | No | A URL query string of field=value pairs | N/A | "Filters": the filters applied before readers see the table. |
| sort | No | Columns, each optionally suffixed with :asc or :desc | The first column, when it can be sorted on | "Sort": the columns the table is sorted on when the Page opens, in order of precedence. |
| layouts | No | table, cards, or both, comma-separated | table | "Layout": how the entries are laid out, as described in Live Data Layouts. The dialog offers one of the two; with both, readers can switch between them. |
| description | No | Any text | N/A | "Description": shown above the table, and used as its accessible description. |
| allowEditMode | No | true or false | false | "Allow edit mode": lets readers switch the table to Edit mode, where they can change the entries they can edit. |
| creationStrategy | No | uuid, title, templateProvider, or the hint of another row naming strategy | N/A: readers cannot add entries | "Creation strategy": how the Pages of the entries added from the table are named. Requires allowEditMode. title and templateProvider also require the doc.title column. |
| newEntriesLocation | No | The reference of a space | The space of the Page holding the table: under it if it is a nested Page, next to it if it is a terminal Page | "New entries location": where the entries added from the table are created. With the templateProvider creation strategy, the first space the template provider restricts creation to is used instead. |
| templateProvider | No | The reference of a template provider, or XWiki.NoTemplateProvider for none | The template provider named after the object type, as AppWithinMinutes names them: e.g., Library.Code.BookTemplateProvider for Library.Code.BookClass | "Template": the template provider whose template the entries added from the table start from. |
| id | No | Any name unique in the Page | A generated identifier | "Table identifier", among the advanced parameters: needed only when one Page holds several tables. |
Examples
Listing Books, Sorted by Year
{{records
class="Library.Code.BookClass"
properties="doc.title,author,year"
sort="year:desc"
/}}Listing the Books Not Read Yet
The status field is filtered on two of its values.
{{records
class="Library.Code.BookClass"
properties="doc.title,author,status"
filters="status=To%20read&status=Reading"
description="Books we have not finished yet."
/}}Letting Readers Add Books
Readers can switch the table to Edit mode and add books, created in Library.Books and named after their title.
{{records
class="Library.Code.BookClass"
properties="doc.title,author,genre,status"
allowEditMode="true"
creationStrategy="title"
newEntriesLocation="Library.Books"
/}}FAQ
Why can readers not add entries?
Adding entries requires allowEditMode="true", and the reader needs edit right on the location of new entries, otherwise the table offers no way to add one.