Data view

Items of any type rendered through your own template, as a list or a responsive grid, with sorting, paging, an empty state and loading placeholders.

  • vig-data-view
Import
import { DataView, DataViewItem } from '@vigdx/ui/data-view';

Basic

Pass items and an ng-template vigDataViewItem ; bind the same items to vigDataViewItemOf so let-product is typed. Each item renders in an <li> of a <ul role="list"> .

  • Bamboo watch

    Accessories

    $65.00
  • Black watch

    Accessories

    $72.00
  • Blue band

    Fitness

    $79.00
  • Blue T-shirt

    Clothing

    $29.00

List and grid

[(layout)] is list or grid ; layoutToggle adds a list/grid vig-select-button to the header, next to any [vigDataViewHeader] content. The template gets layout in its context. The grid fills columns of at least --vig-data-view-item-min-width (15rem) and drops to one column in a narrow container; items stretch to the row height, so cards line up.

Accessories

  • Bamboo watch

    Accessories

    $65.00

  • Black watch

    Accessories

    $72.00

  • Bracelet

    Accessories

    $15.00

  • Brown purse

    Accessories

    $120.00

  • Chakra bracelet

    Accessories

    $32.00

  • Galaxy earrings

    Accessories

    $34.00

Layout: grid

Sorting and paging

sort is typed against the items: { by: (item) => value } (empty values first, numbers and dates numerically, text by the locale's collator) or { compare: (a, b) => number } , with direction asc or desc ; sorting is stable. A new sort goes back to the first page and, with a label , is announced once with the item count. paginator adds a vig-paginator ( true , or { position, rowsPerPageOptions, jumpToPage, size } ), named by labels.paginatorAriaLabel ("Item pages"), bound to [(first)] and [(rows)] . itemId keeps each item's element across sorts and new arrays.

Sort by

  • Bamboo watch

    5 / 5$65.00
  • Black watch

    4 / 5$72.00
  • Blue band

    3 / 5$79.00
  • Blue T-shirt

    5 / 5$29.00
  • Bracelet

    4 / 5$15.00

Empty and loading

Without items the data view shows a small vig-empty-state (heading labels.emptyLabel ), or your ng-template vigDataViewEmpty . loading shows skeleton placeholders (a page's worth with the paginator, at most 12, else 3), or one vigDataViewLoading template per placeholder, and disables the paginator.

  • Bamboo watch

    Accessories

  • Black watch

    Accessories

  • Blue band

    Fitness

Server-side paging

Set totalRecords to the server's count: items is then the page at first and is shown as given. Load from the bound models, e.g. with a resource whose params read first() and rows(), and set loading while a page is on its way. Sort on the server too: in this mode sort only describes the order of items and is not applied again, but a new sort still goes back to the first page and is announced, with totalRecords as the count, once the page has loaded.

Every item on the page is rendered: there is no virtual scrolling. Page long lists, or show very long ones in vig-table with virtualScroll.

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="data-view"][data-part="header"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="data-view"]

DataView styling hooks
Part Element data-state
header The row of the [vigDataViewHeader] content and the layout toggle. —
layout-toggle The list/grid vig-select-button ; style its [data-scope="select-button"] parts. —
status The visually hidden polite region (loading, sorted). —
list The <ul role="list"> of the items, as a list or a grid. —
item One <li> around an item template. —
empty Wrapper of the empty state or the vigDataViewEmpty template. —
loading The hidden container of the placeholders ( loading ). —
placeholder One skeleton or vigDataViewLoading placeholder. —
paginator The vig-paginator ( paginator ); style its own parts. —

Accessibility

  • Items render as a list in both layouts (role="list" keeps list semantics in Safari, which drops them for unstyled lists), so screen readers announce the count and each position. Give items a heading of the right level for the page and real controls: the data view adds no keyboard handling of its own, so Tab moves through the items' controls.
  • The layout toggle is a radio group named "Layout" (labels.layoutAriaLabel); its options carry visually hidden text next to the icons.
  • Sorting moves the existing elements (tracked by itemId), keeping focus inside an item. A sort with a label is announced once through a polite status ("Sorted by Price, low to high"), and so is loading; the placeholders are hidden from screen readers.

API

DataView

vig-data-view component

Items of any type rendered through your own template, as a list or a responsive grid, with optional sorting, paging, a layout toggle, an empty state and loading placeholders.

Example :
<vig-data-view [items]="products" [(layout)]="layout" layoutToggle paginator>
  <ng-template vigDataViewItem [vigDataViewItemOf]="products" let-product>
    <h3>{{ product.name }}</h3>
  </ng-template>
</vig-data-view>

Items render in a <ul role="list">, one <li> each, in both layouts; headings and controls inside an item are the template's. The grid fills columns of at least --vig-data-view-item-min-width (15rem), one column on a narrow container. sort orders the items in memory; paginator shows a vig-paginator and pages them, or — with totalRecords — shows items as the current page of a server-side list, whose first and rows you load from. Every item is rendered: page long lists, or use vig-table's virtual scrolling for very long ones.

DataView props
Name Type Default Description
first model number0

Zero-based index of the first item on the page.

itemId((item: T) => unknown) | undefinedundefined

Identity of an item, so its element survives sorting and new arrays; the item itself by default.

itemsreadonly T[][]

The items. With totalRecords, the current page only.

labelsPartial<DataViewLabels>—

Texts (i18n); locale defaults.

layout model DataViewLayout'list'

list (default) or grid; two-way bindable.

layoutTogglebooleanfalse

Shows a list/grid toggle in the header.

loadingbooleanfalse

Shows placeholders instead of the items, and a "Loading" status.

paginatorDataViewPaginatorOptions | nullnull

Pages the items with a vig-paginator: true, or its options.

rows model number10

Page size.

sortDataViewSort<T> | null | undefinedundefined

The order of the items: an accessor (by) or a comparator (compare). A new sort goes back to the first page and is announced with its label. With totalRecords the server sorts: the sort then only describes the order of items (announced, not applied).

totalRecordsnumber | undefinedundefined

Total count of a server-side list: items is then the page at first and is shown as given. Unset, the data view pages items itself.

DataViewItem

ng-template[vigDataViewItem] directive

Renders each item of vig-data-view; layout in the context tells list from grid. Bind the items to vigDataViewItemOf to type let-item:

Example :
<ng-template vigDataViewItem [vigDataViewItemOf]="products" let-product let-layout="layout">
  …
</ng-template>
DataViewItem props
Name Type Default Description
vigDataViewItemOfreadonly T[] | null | undefinedundefined

Type-only: the items the template renders, so let-item is typed. Not read at runtime.

Templates and directives

Templates and directives
Selector Export Description
ng-template[vigDataViewEmpty]DataViewEmpty

Replaces the default empty state of vig-data-view.

ng-template[vigDataViewLoading]DataViewLoading

One loading placeholder of vig-data-view, in place of the default skeleton.

[vigDataViewHeader]DataViewHeader

Marks projected content (a heading, a sort select) for the data view's header row.

Are you sure?