Skip to main content

Views

Views define how a list of objects is displayed as a table or column-based overview. A class can have multiple views — a default view, a relation view, and any number of named views.

Definition

{
"name": "openTasks",
"defaultView": false,
"relationView": false,
"defaultSort": "dueDate,desc",
"values": [
{ "name": "title" },
{ "name": "status", "dataType": "LIST", "list": "my-project.taskStatus" },
{ "type": "RELATION", "relatedClass": "commons.person" }
],
"filter": [
{ "name": "status", "value": "open" }
]
}
PropertyTypeDescription
namestringOptional name. When set, this view is selected by name matching (e.g. in a VIEW layout item with the same name).
defaultViewbooleanWhen true, used as the default for class dashboards and unnamed view embeds.
relationViewbooleanWhen true, used for related-object list tabs (rendered by RELATED_VIEW layout items).
defaultSortstringDefault sort order in REST API format: fieldName for ascending, fieldName,desc for descending.
valuesLayoutItem[]Column definitions. Each entry is a FIELD or RELATION layout item.
filterViewFilter[]Static pre-filters automatically applied when this view is displayed.

Columns

The values array defines which columns are shown in the view. Each entry uses the same structure as Layout items — only FIELD and RELATION types are supported here.

"values": [
{ "name": "lastName" },
{ "name": "firstName" },
{ "type": "RELATION", "relatedClass": "commons.company" }
]

Filters

filter defines static pre-filters that are always active for this view. These cannot be overridden by the user.

PropertyDescription
nameWhat to filter on: a value type field name, a relation type as a TypeFQN string, or "type" to restrict to a specific concrete subtype.
valueThe filter value.

Examples:

Filter on a value type field:

{ "name": "status", "value": "active" }

Filter on a relation (only objects linked to a specific object of this type):

{ "name": "commons.country", "value": "nl" }

Restrict to a specific subtype:

{ "name": "type", "value": "my-project.contractor" }

Selecting views

Views are selected by the platform as follows:

  • Class dashboards — the view with defaultView: true is used.
  • VIEW layout item — if name is set, the view with that name is used; otherwise the view with defaultView: true.
  • RELATED_VIEW layout item — the view with relationView: true is used; if name is set, the view with that name is used instead.

Example

A class with two views — a default view for the list page, and a named compact view for embedding:

"views": [
{
"defaultView": true,
"defaultSort": "name",
"values": [
{ "name": "name" },
{ "name": "status" },
{ "name": "dueDate" },
{ "type": "RELATION", "relatedClass": "commons.person" }
]
},
{
"name": "compact",
"defaultSort": "dueDate",
"values": [
{ "name": "name" },
{ "name": "dueDate" }
],
"filter": [
{ "name": "status", "value": "open" }
]
}
]