Create

General

Data Table

New
Copy page View as Markdown Open in ChatGPT Open in Claude

A table that sorts, filters, groups, edits and virtualizes rows from columns and data you pass in.

Usage#

app.component.ts
import { WdsDataTableComponent } from '@wds/angular/data-table';

Examples#

Default#

columns and data are properties (in HTML set them from a script). A column reads row[key]; format turns the value into text, sortable sorts by a click on the header and align aligns the cells. page-size="0" turns pagination off.

Selection, filter and actions#

selectable adds checkboxes (Select all works on the current page) and fires wds-selection-change. filterable adds a filter field that searches every column without filterable: false; column-toggle adds a menu for hiding columns. A column with actions gets a menu in every row, and the chosen item comes in wds-row-action with its row. With more rows than page-size (default 10) the table paginates.

Selected: 0 · Last action: none

Custom cells#

render returns the cell content as text or a DOM node; it takes precedence over format. Here statusBadge() from the payments file creates a wds-badge; the other examples use it for their status columns too.

Filter bar#

A Filters bar in the toolbar slot filters the rows by itself. A column with filter becomes a field of the bar: a type ('text', 'number', 'date', 'boolean') or a field such as { type: 'select', options }. The bar fires wds-change; in manual mode send its filters to the server.

Column reordering#

reorderable adds a handle to the headers: drag it, or focus it and press ← or →. The new order comes in wds-column-order-change; keep it and pass it back in column-order. The actions column stays in place.

Order: status, email, date, amount

Grouping#

group-by groups the rows by a column. A group row shows the value, the number of rows and a button that collapses the group; a column with aggregate (sum, avg, min, max, count or a function) shows its summary in the group row, formatted with format. Collapsed groups take one row of a page.

Group by statusGroup by dateNo grouping

Editing#

A column with editable turns its cells into buttons: a click or Enter opens an editor (text, number, or select with options). Enter or leaving the field saves, Escape cancels. The table does not change data: wds-cell-edit gives the row, the column and the new value, so replace the row yourself.

Last edit: none

Expandable rows#

renderDetail returns the content of an expanded row (text or a DOM node); every row gets a button that shows it in a full-width row below. The content is placed in the page, so utility classes work in it. rowExpandable decides which rows can expand; expanded and wds-expanded-change keep the open rows.

Virtual scrolling#

virtual renders only the rows in view, here 10,000 of them. The rows scroll under a sticky header in an area of --wds-data-table-height (default 400px); the column layout is fixed, so give the columns a width. Rows are measured as they render, so grouping and expanded rows work too; row-height is the first estimate.

Server-side#

With manual the table does not sort, filter or paginate: it keeps page, sort-key and filter, fires wds-page-change, wds-sort-change and wds-filter-change, and shows the rows it is given. row-count is the total for the page count; loading shows a spinner over the rows. After a new sort or filter the table goes back to page 1.

Adding rows#

The toolbar slot adds items to the bar above the table, and empty-text (or the empty slot) replaces the text of an empty table. In Angular the form opens in a drawer from WdsDrawerService; HTML and React have no service, so their tabs declare the drawer in the markup.

Add payment

API References#

wds-data-table#

A table built from columns and data properties that sorts, filters, paginates, hides columns and selects rows by itself. In manual mode the server does these operations: the table only fires events and shows the page of data it is given. Data grid features: column reordering (reorderable), grouping (group-by), cell editing (editable columns), expandable rows (renderDetail) and virtual scrolling (virtual). A wds-filters bar in the toolbar slot filters the rows.

Attributes

AttributeTypeDefaultDescription
row-key.rowKeystring'id'Row field with a unique key (used by selection, row actions, expanded rows and editing).
selectablebooleanfalseA column of checkboxes and a count of selected rows.
selectedstring[]Keys of the selected rows. In HTML a space-separated list.
filterablebooleanfalseA filter field above the table (searches all columns without filterable: false).
filterstring''Filter text.
filter-placeholder.filterPlaceholderstring'Filtruj…'Placeholder of the filter field (also its accessible name).
column-toggle.columnTogglebooleanfalseA columns menu for hiding columns.
hidden-columns.hiddenColumnsstring[]Keys of the hidden columns. In HTML a space-separated list.
reorderablebooleanfalseColumns can be moved: drag the handle in a header, or focus it and press ← or →.
column-order.columnOrderstring[]Keys of the columns in display order (columns not listed follow in the order of columns). In HTML a space-separated list.
group-by.groupBystring''Key of the column whose values group the rows (a group row with a count and the column aggregates).
expandedstring[]Keys of the expanded rows. In HTML a space-separated list.
virtualbooleanfalseRenders only the rows in view, for thousands of rows (usually with page-size="0"). The rows scroll under a sticky header in an area of --wds-data-table-height; columns get a fixed layout, so give them a width.
row-height.rowHeightnumber37With virtual: the estimated row height in px (rows are measured as they render).
sort-key.sortKeystring''Key of the sorted column (empty: the order of data).
sort-direction.sortDirectionWdsDataTableSortDirection'asc'Sort direction.
pagenumber1Current page (from 1).
page-size.pageSizenumber10Rows per page; 0 turns pagination off.
page-sizes.pageSizesnumber[][10, 20, 25, 30, 40, 50]Options of the rows-per-page select.
manualbooleanfalseSorting, filtering and pagination on the server: the table only fires events.
row-count.rowCountnumber0In manual mode: the total number of rows (for the page count).
empty-text.emptyTextstring'Brak wyników.'Text shown when there are no rows.
loadingbooleanfalseLoading data: a spinner in place of the rows (empty table) or an overlay on the current rows (such as while changing pages in manual mode). The table then has aria-busy.
loading-text.loadingTextstring'Ładowanie…'Text next to the spinner.
labelstring''Accessible name of the table.
localestring''Locale used to compare text when sorting (default: the browser's).

Properties

PropertyDescription
columnsWdsDataTableColumn[]Column definitions (WdsDataTableColumn[]).
dataany[]Rows (in manual mode only the current page).
filtersWdsFilter[]Field filters (WdsFilter[], joined with AND): field is a column key. Set by a wds-filters bar in the toolbar slot; in manual mode only kept (send them to the server).
renderDetail(row: any) => string | Node | undefinedContent of an expanded row (text or a DOM node). When set, every row gets a button that shows the content in a full-width row below it. The content is placed in the light DOM (slot detail-<row key>), so page styles apply.
rowExpandable(row: any) => boolean | undefinedWhich rows can be expanded (default: all, when renderDetail is set).

Events

EventDescription
wds-sort-changeCustomEvent<WdsDataTableSortChangeDetail>The sort order changed.
wds-filter-changeCustomEvent<WdsDataTableFilterChangeDetail>The filter text changed.
wds-page-changeCustomEvent<WdsDataTablePageChangeDetail>The page or the number of rows per page changed.
wds-selection-changeCustomEvent<WdsDataTableSelectionChangeDetail>The selected rows changed.
wds-visibility-changeCustomEvent<WdsDataTableVisibilityChangeDetail>A column was hidden or shown.
wds-column-order-changeCustomEvent<WdsDataTableColumnOrderChangeDetail>A column was moved.
wds-expanded-changeCustomEvent<WdsDataTableExpandedChangeDetail>A row was expanded or collapsed.
wds-cell-editCustomEvent<WdsDataTableCellEditDetail>A cell was edited; update data with the new value.
wds-row-actionCustomEvent<WdsDataTableRowActionDetail>An item was chosen in the row actions menu.

Slots

SlotDescription
toolbarExtra items in the bar above the table (such as an “Add” button or a wds-filters bar).
emptyContent shown when there are no rows (instead of empty-text).
loadingContent of the loading indicator (instead of the spinner with loading-text).

CSS parts (::part)

PartDescription
toolbarThe bar above the table (filter, columns menu).
filterThe filter field.
containerThe table border (scrolls horizontally; with virtual also vertically).
tableThe <table> element.
footerThe bar below the table (selection count, pagination).
loadingThe loading indicator (an overlay on the rows, or the row of an empty table).

CSS custom properties

PropertyDescription
--wds-data-table-heightHeight of the scrolling area with virtual (default 400px).

Accessibility#

Screen reader#

The table is a native <table> with <th scope="col"> headers; label gives it an accessible name. While loading it has aria-busy="true" and the spinner has role="status".

A sortable header is a button inside the <th>, which has aria-sort (ascending or descending) on the sorted column.

The filter field is named by filter-placeholder. After typing stops, the number of results is announced in a live region; the selection count below the table is also a live region.

Row checkboxes, the Select all checkbox, the row actions button and the pagination buttons have accessible names. These texts are built in and are in Polish for now (such as Zaznacz wiersz 1, Wierszy na stronę); empty-text, filter-placeholder and loading-text can be changed.

A column with actions has a visually hidden header text (its header, default Akcje).

With reorderable, the header handle is a button (Przesuń kolumnę Email) described by the arrow-key hint; the new position is announced (Email: kolumna 2 z 4).

A group row has a button with aria-expanded; the expand button of a row has aria-expanded and aria-controls pointing to the detail row.

An editable cell is a button named by its value and column ([email protected], edytuj: Email); the editor is named by the column header.

With virtual the table has aria-rowcount and every rendered row aria-rowindex, so screen readers know the position of the rows in view.

Keyboard support#

KeyFunction
TabMoves focus through the filter, the columns menu, the column handles and sortable headers, the row checkboxes, expand buttons, editable cells and action menus, and the pagination controls.
EnterSpaceOn a sortable header: sorts ascending, then descending, then turns sorting off. On a checkbox: toggles the row. On a group or expand button: collapses or expands. On an editable cell: opens the editor.
ArrowLeftArrowRightOn a column handle (reorderable): moves the column one place.
EnterIn a cell editor: saves the value. Tab and clicking elsewhere also save.
EscapeIn a cell editor: cancels the edit and returns focus to the cell.
Footer