[data-reveal]{opacity:1!important;transform:none!important}
AntelopeJS DMS
DocumentationTables

Tables

TableView over a data controller: columns, routes, row actions, displays, filters and the forms it opens.

Overview

A table view is built from a data controller. You declare the controller's routes with TableViewRoutes, annotate its fields with @Column, and then call TableView(controller, options) to get the component. The builder reads the controller's data-api metadata (access modes, mandatory modes, listable flags, sortability) and combines it with the column options to produce the column list, the new / edit / view forms, and the set of permission-carrying actions.

Everything on this page is exported from the table-view module, reachable from the package root or from its own subpath:

typescript
import { Column, TableView, TableViewRoutes } from "@antelopejs/interface-dms/base";

Or import directly from the table-view subpath:

typescript
import { Column, TableView } from "@antelopejs/interface-dms/base/table-view";

Declare the data controller

TableViewRoutes.All is the route set a table view expects. Field decorators from @antelopejs/interface-data-api/metadata stay exactly as they are on any data controller; @Column is added on top of them.

typescript
import { Controller } from "@antelopejs/interface-api";
import {
  DataController,
  RegisterDataController,
} from "@antelopejs/interface-data-api";
import {
  Access,
  AccessMode,
  Listable,
  Mandatory,
  ModelReference,
  Sortable,
} from "@antelopejs/interface-data-api/metadata";
import { Model } from "@antelopejs/interface-database-decorators";
import {
  Column,
  Exported,
  Searchable,
  Select,
  TableViewRoutes,
} from "@antelopejs/interface-dms/base";
import { DefaultDataTypes } from "@antelopejs/interface-dms/base/data-types";
import { ReadonlyBehaviorType } from "@antelopejs/interface-dms/base/types";
import { Role, RoleModel } from "./db";

@RegisterDataController()
export class roleDataAPI extends DataController(
  Role,
  TableViewRoutes.All,
  Controller("/api/tables/roles"),
) {
  @ModelReference()
  @Model(RoleModel)
  declare model: RoleModel;

  @Select()
  @Listable()
  @Exported()
  @Access(AccessMode.ReadOnly)
  declare _id: string;

  @Select()
  @Listable()
  @Searchable()
  @Exported()
  @Column({
    name: "Name",
    type: new DefaultDataTypes.StringType({ placeholder: "Role name" }),
    filterable: true,
  })
  @Mandatory("new", "edit")
  @Sortable()
  @Access(AccessMode.ReadWrite)
  declare name: string;

  @Exported()
  @Column({
    name: "Created at",
    type: new DefaultDataTypes.DateType(),
    readonlyBehavior: {
      new: ReadonlyBehaviorType.hidden,
      edit: ReadonlyBehaviorType.disabled,
      view: ReadonlyBehaviorType.disabled,
    },
  })
  @Access(AccessMode.ReadOnly)
  declare createdAt: Date;
}

TableViewRoutes

RouteEndpoint role
GetRead one row: its readable fields (RowFields).
ListPaginated list with search, filters and sorting: a TableViewListPage, { results, total, offset, limit }, each result the row's listable fields (RowFields). A wrapper reads a field through a guard.
SelectList with the select pluck mode, used by relation pickers. ?ids=a&ids=b (with idKey when the value is another field) answers those rows alone, as List does: a picker and a filter chip name the ids they hold this way.
CountRow count for the current query.
CountBatchOne count per repeated query value in GET /count/batch (tab, view and group counters). Each value is encodeURIComponent(id) + "?" + listQueryString, with repeated filters preserved. Requests accept up to 50 entries and 8,192 UTF-8 bytes in the encoded path plus search; the client packs larger batches into bounded GET requests.
SummaryGET /summary?ids=…: the footer summaries a table view declared, over every row the request's filters list.
NewCreate a row.
EditUpdate a row.
DeleteDelete rows.
ArchiveSet the archive field on rows.
RestoreClear the archive field on rows.
ExportRoutesA record with exportStart (/export/start), exportStatus (/export/status/:exportId) and exportDownload (/export/download/:exportId).
AllEvery route above, spread into one object.

These are not the plain data-api defaults. Every route asserts tenant access and the action's permission; the mutating ones also run the matching guard and publish the mutation to the table's realtime topic, and Edit, Delete, Archive and Restore also validate the affected rows against the action's rule. New and Edit promote staged file uploads before writing, and Edit and Delete remove the files a row no longer references afterwards. Passing a narrower set than All removes the corresponding capabilities. The export action, for instance, is offered only when all three ExportRoutes endpoints are registered.

@Searchable on the example's name field is what makes the list route's free-text search consider that column; it is documented in Helpers.

The Column decorator

@Column is a method-and-property decorator. It records the column, and unless validate is false it registers a data-api Validator built from the data type's getValidation() schema (wrapped for localization when the underlying table field carries the LocalizationModifier). When filterable is set it registers the data type's filter implementation as the field's data-api Filter. Finally, if the data type defines decorateField, that hook runs. A relation type installs its Foreign join this way.

OptionTypeDescription
namestringColumn header, and the label of the generated form field. Required.
typeDataTypeData type instance. Required.
descriptionstringDescription carried onto the generated form field.
ordernumberSort key among columns; missing values sort as 0.
isVisiblebooleanWhether the column is shown by default. false hides it until the user picks it in the column menu.
defaultValueDefaultValueDefault value for the column and the generated form field.
readonlyBehaviorReadonlyBehaviorPer-mode behaviour for a read-only field; see Shared types.
validatebooleanSet to false to skip registering the validator.
filterablebooleanRegister the type's filter and allow column filtering.
inputComponentComponentOverrides the input component the data type supplies.
groupstringIdentifier of the ColumnGroup this column belongs to in the generated forms.
cellWrapbooleanWrap the grid cell without a line limit.
sizenumberDefault width of the grid column in px (150 when omitted).
visibleWhenFieldCondition{ field, in }: the form field shows only while the column field holds one of the values in lists (null for an empty one). The data routes hold to it too: hidden, the field is not mandatory, the value sent for it is ignored, and an edit clears the value it stored.
disabledWhenFieldConditionSame shape: the form field is read-only while the condition holds, and the data routes ignore the value sent for it.
displayColumnDisplayA display class instance (new DefaultDisplays.IdentityDisplay({ … }), or a module's own @RegisterDisplay("<module>:<id>") class) the grid cells (and expanded-row fields) render with, its options typed by the class. type keeps driving forms, filters, validation and exports; the formatter also receives the row. Serialized as { type, options? }.

A field is read-only in a form when its @Access for the action that form runs is AccessMode.ReadOnly: the per-action override (@Access(AccessMode.ReadWrite, { new: AccessMode.ReadOnly }), keyed new, edit and get for the view form) where it declares one, else its default access: the access the data API applies to the value it writes. Such a field is disabled in that form, or dropped from it when its readonlyBehavior resolves to hidden for the mode; a field whose data type has no input component is dropped from every form.

visibleWhen and disabledWhen make a field depend on the value of another column, with no watch: the generated forms apply them from the values they open with, and the new and edit routes (TableViewRoutes.New, Edit, EditWith) apply them to what they write, read on the row as it will be stored, an edit's stored row under its body. A hidden or disabled field leaves the body before the guard runs, and an edit clears the value a hidden field stored (a disabled one keeps its own); @Mandatory binds a field with visibleWhen only while it shows, and there an edit must leave it filled (a deal moved to lost without its reason is refused with 400 { code: "missing_mandatory_fields", fields: ["lostReason"] }, as the data API refuses any mandatory field). A condition naming an unknown column, the column itself or no value throws at registration.

ts
@Mandatory("new", "edit")
@Column({ name: "Loss reason", type: reasonType, visibleWhen: { field: "stage", in: ["lost"] } })
declare lostReason: string;

@Column({ name: "Probability", type: percentType, disabledWhen: { field: "stage", in: ["won", "lost"] } })
declare probability: number;

Column groups

ColumnGroup(id, config) is a class decorator on the data controller. Columns join a group by naming its id in ColumnOptions.group; the generated forms then render a FieldGroup in the position of the group's first column.

typescript
import { Column, ColumnGroup } from "@antelopejs/interface-dms/base/table-view";

@ColumnGroup("contact", { label: "Contact", orientation: "horizontal", order: 2 })
export class customerDataAPI extends DataController(/* … */) {
  @Column({ name: "Email", type: new DefaultDataTypes.EmailType(), group: "contact" })
  declare email: string;

  @Column({ name: "Phone", type: new DefaultDataTypes.PhoneType(), group: "contact" })
  declare phone: string;
}

ColumnGroupConfig has label: string (required), description?, orientation?: "horizontal" | "vertical" and order?: number.

select and exported

@Select(requiredFields?) and @Exported(requiredFields?) mark a field as listable in the select and export pluck modes respectively. Both forward to Listable from @antelopejs/interface-data-api/metadata with the corresponding mode, and both accept the same boolean | string[] argument that Listable takes for dependent fields.

The archive field

@ArchiveField marks the boolean field that carries the archived state. It makes the field Listable() and registers a filter that reads true or false with eq or ne. TableView throws when another Filter replaces it.

typescript
import { ArchiveField } from "@antelopejs/interface-dms/base/table-view";

@ArchiveField()
@Access(AccessMode.ReadOnly)
declare archived: boolean;

DEFAULT_ROW_ID_FIELD is the constant "_id": the row identifier used when TableViewOptions.rowIdKey is not set.

Build the table view

TableView returns a ComponentBuilder<TableViewOptionsSerialized>, assigned to a static field of a page class.

typescript
import {
  PageController,
  pagesCategory,
  RegisterPage,
} from "@antelopejs/interface-dms/page";
import { TableView } from "@antelopejs/interface-dms/base";
import { roleDataAPI } from "./role-data-api";

@RegisterPage()
export class RolesPage extends PageController("roles", {
  displayName: "Roles",
  icon: "i-ph-shield-check",
  category: pagesCategory,
}) {
  static table = TableView(roleDataAPI, {
    caption: "Roles",
    labelKey: "name",
    rowActions: {
      add: true,
      edit: true,
      delete: true,
      details: true,
      hasSelection: true,
    },
  });
}

Signature

typescript
function TableView<T extends ControllerClass>(
  controller: T,
  options?: TableViewOptions<InstanceType<T>>,
): ComponentBuilder<TableViewOptionsSerialized>;

Typing TableViewOptions by InstanceType<T> is what makes row-action rules field-name-checked against the controller's own fields.

TableViewOptions

OptionTypeDescription
captionstringTable caption; also the component's display name, defaulting to "TableView".
layoutTableViewLayout"full" (default): the dashboard grid; "compact": the list of a settings page (tabs, open search, quick filters, the footer's page size picker; no caption, refresh, ⋯ menu nor column menus). Either way, search shows only with @Searchable fields, filters only with a filterable column, the caption only when caption is set.
searchPlaceholderstringPlaceholder of the search field, also its accessible name.
searchShortcutstringKey opening and focusing the search, in Nuxt UI defineShortcuts notation ("/", "shift_f"): "shift_f" (⇧F) by default. It does not fire while the user types in a field.
quickFiltersTableViewQuickFilter[]{ field, label?, icon?, allLabel?, mode? } dropdown filters over a filterable column's values, mode a TableViewQuickFilterMode. The picked value is the column's own filter: kept with the table state, counted, cleared by "Clear filters"; in the compact layout the button reads "Role: Admin" with a clear button. Unknown or non-filterable columns throw. The column needs values to list (a select with items, a boolean, a status, a relation, or an input declaring items or a searchUrl): on any other, such as a free-text string, the toolbar leaves it out and registration logs a warning.
pageSizenumberRows per page while the user picked none (default 10), 1 to 50: registration throws above. A size other than 10, 25 and 50 joins them in the table's page size picker.
paginationTableViewPaginationMode"pages" (default): a pager; "loadMore": a "Load more" button; "infinite": the next page loads as the footer scrolls into view. The last two ask for every page loaded so far, from the first row, so a refresh re-reads them.
footerTableViewFooterOptions{ countLabel?, hint?, summary?, legend? }: the footer's row count ($ key pluralized on { count }) and hint; summary figures (TableViewFooterSummary: label, field?, op: "sum" | "count", where? row rule, format? TableViewSummaryFormat) computed by the Summary route over every listed row; legend, a SelectType column. Serialized as TableViewFooterSerialized: each summary gets an id, its where stays server-side (TableViewMeta.footerSummary(id)). A sum without field, an unknown column or a legend that is no select column throws.
emptyStatesTableViewEmptyStates{ firstRun?, filtered?, error? }, each a TableViewEmptyState (title, description?, icon?, actions?: BlockLinkAction[], component?) the empty body of the grid and the cards display shows instead of the built-in words, its texts (keys and literals alike) receiving { search }. A component receives state, search, refresh(), and clearSearch() / clearFilters() while there is a search or a filter chip to clear.
expandableTableViewExpandableOptionsExpandable rows, a union: { fields, fieldsLabel? } (column keys or { key, label?, fullWidth?, hideEmpty? }, each rendered by its column's data type) or { component } (receives TableViewExpandedRowProps: row, rowId, columns, labelKey, actions, open and refresh, and draws the whole band), plus defaultExpanded ("none" | "first" | "all"), single and lazyLoad (read the row from get when it opens). Fields must name declared columns; both or neither throws. Serialized as TableViewExpandableSerialized.
rowIdKeystringField holding the row id. Defaults to DEFAULT_ROW_ID_FIELD.
labelKeystringField naming a row: it follows the drawer or modal title ("Edit task · Write the docs") and ends the breadcrumb of the edit and details pages (set on their forms as labelKey).
rowActionsTableViewRowActionOptions<T>Built-in and custom row actions.
columnsTableViewColumnsOptionsThe controller's columns as this table view shows them: hidden lists the ones it opens hidden, as isVisible: false does on the @Column, for this table view only (they stay in the column menu, filterable and in the forms). A name the controller has no column for throws at registration.
customButtonsCustomButton[]Toolbar buttons; see Shared types.
formsPartial<Record<"new" | "edit" | "view", TableViewFormSetup>>A callback per generated form, (form: FormBuilder) => void, receiving its builder before the table view embeds it, for input comfort only: what it declares (.watch(), a value filled in from another, a field one table's forms leave out) holds in a drawer, a modal or a form page alike. No data rule here, the routes never see it: a field shown, required or locked by another's value is a column's visibleWhen / disabledWhen.
formContainerFormContainerWhere the new / edit / view forms open.
archiveModebooleanReplace delete with archive/restore. Requires @ArchiveField.
archivedCountLabelstringHow the footer counts the archived rows: an i18n key with $ receiving { count } and pluralized on it, or a text with {count}. Defaults to "Archived: {count}", which agrees with no noun.
defaultFiltersArray<{ accessorKey: string; value?: string; mode: string }>Filters applied when the table opens.
defaultSort{ field: string; desc?: boolean }Sort applied when the viewer has no stored preference, and the one a cleared sort goes back to.
pinnedRowsRowActionRule<T>Rows listed first whatever the sort, in the sort's order among themselves: within the list the route answers (a source without paginate answers every row, so its pinned rows open the first page; a paging route's open their page). The grouped display pins only with grouped.pinned; registration throws beside reorder.
queryParamFiltersQueryParamFiltersMaps URL query parameters onto hidden filters.
routeParamFiltersRouteParamFiltersMaps DMS route parameters onto hidden filters.
strictRuleValidationbooleanReject the whole request when any row fails rule validation, instead of processing only the eligible rows.
tabsTableViewTab[]Tabs above the table, each applying a hidden filter on one column (filter optional). A tab may link to another page instead (to: page controller or path, countFrom: data controller or location for its counter); a tab with id "all" replaces the implicit one; permission (an action of the table) or permissionId (an absolute id) gates it; navBadge (true, or { tone }) publishes its counter as the page's nav badge. Serialized as TableViewTabSerialized (to resolved per request, toPage).
realtimebooleanSet to false to disable realtime broadcast and presence for this resource. Realtime is on by default.
realtimeTopicstring | string[]Topics the backend publishes on when rows change outside the table's routes: the table reads its rows again on each event. Registered against the page from onCreated; also offered by TableView.fromSource.
liveHoldTableViewLiveHoldOptionsOn a page declared with live, keeps the rows while the page is paused, and shows a "N new · Show" pill over the rows, which moves nothing, counting the rows its tab, search and filters match now beyond those it holds (asked of its count route), not the events; Show reads them once without leaving the pause. whileOnScreen is required: true also holds the rows in Direct while they are on screen or scrolled past (a new row at the top would push them down), false lets them follow the feed. whileRowOpen?, whileScrolled?, whileSearching? and whileSorted? (all default false) also hold the table alone, the page staying live, while a row is open in a row action's side panel or drawer, its first row is scrolled out of view, the user's search narrows the rows or they are sorted otherwise than by defaultSort; the strip then names the reason ("Table on hold · search active"). missedLabel words the strip's count, given {count} ("12 new requests"); while the page is paused the strip adds the page's setMissedDetail breakdown. A TableView.fromSource route receives liveHeldAt (ISO 8601) on every request made while held. Also offered by TableView.fromSource.
reorderTableViewReorderOptions{ field }: rows ordered by hand with a drag handle, on the grid and on the cards display. field must be a @Sortable(), writable NumberType column, and the edit action on: registration throws otherwise. The rows are listed sorted on it, and a move saves only the rows whose value changed.
kanbanKanbanOptionsEnable the kanban display.
groupedGroupedOptions{ groupByField, by?: "value" | "day" | "week", order?, collapsible?, count? }: offer the grouped display: a header row per group, in order. groupByField must be a @Sortable() column, a DateType one to group by day or week.
viewsTableViewViewsOptions{ items: TableViewView[], layout?: "tabs" | "strip" | "menu", defaultView?, userViews? }. A TableViewView is a TableViewViewState (filters, search, sort, columns: { visible?, hidden?, order? }, display, density) with id, label, icon, tone, dot, count, permission (an action of the table by name, or an Action) and permissionId (an absolute permission id, which wins); a view the caller fails it for is left out when the layout is served. Filter values may hold {{user.id}}, {{now}} and {{now±Nd}}, resolved by the server. Serialized as TableViewViewsSerialized (no permission nor permissionId).
cardTableViewCardOptionsThe card the kanban and cards displays draw: fields it shows, or a component drawing it whole; minWidth (a CSS length, "230px" by default) is the narrowest a card of the cards grid gets.
displaysTableViewDisplayOption[]The displays offered, in order: a built-in id ("table", "cards") without a component, or a module display named <module>:<id>; registration throws otherwise. Left out, the built-in table alone; listed, exactly these, so the grid is kept by listing { id: "table" }.
defaultDisplaystringDisplay shown when the viewer has no stored preference. Defaults to "table".
mobileDisplaystringDisplay a phone (narrower than 768px) opens on when the viewer has no stored preference, e.g. "cards". Registration throws when it is not among the displays offered.
guardsTableViewGuards<T>Server-side guards run before mutating actions.
bypassTenantAccessGatebooleanSkip the tenant access gate on every data route of this table view.

TABLE_DISPLAY_ID ("table"), KANBAN_DISPLAY_ID ("kanban"), CARDS_DISPLAY_ID ("cards") and GROUPED_DISPLAY_ID ("grouped") are exported constants for the reserved built-in display ids. TableViewOptionsSerialized is the transported shape: customButtons, rowActions, displays become their serialized counterparts, kanban and grouped are folded into displays, and two fields are added: enableTableExport: boolean and formComponents, a record of the serialized new / edit / view forms. When a page is served, each table view on it also receives tableId (its key in the page) and isSoleTableView, which decide the URL keys opening its views and tabs (?<tableId>.view=, or ?view= for a page's only table view).

tableViewLink(page, tableId, { view?, tab? }) returns the dashboard path of page opening one of its table views on a view or a tab (/workspaces?content.view=past-due); it throws for a class that is no page controller. TABLE_VIEW_VIEW_QUERY_KEY ("view") and TABLE_VIEW_TAB_QUERY_KEY ("tab") are the keys it uses.

TableView throws at declaration time when the options do not hold together: archiveMode without an @ArchiveField, a kanban.groupByField that is not a column or whose type is not a non-multiple SelectType, a BooleanType or a StatusType, a card.fields entry that is not a column, a grouped.groupByField that is not a sortable column (or not a date one, by day or week), a defaultDisplay that no declared display provides, displays: [] with neither kanban nor grouped (no display at all), or views that repeat an id, filter on a column that is not filterable, sort on one that is not sortable, name an unknown column, open a display the table does not offer, or default to an undeclared view.

Next steps