Skip to content

features

What the grid does beyond showing, sorting and selecting rows: each feature is added on purpose, and a page loads only the code of those it uses.

Typereadonly GridFeature[]
Default[]
Live update (update())No — read once, when the grid is made
Angularthe [features] input
<dz-grid>the features property
Declared inpackages/dom/src/settings.ts

A list of features, each made by a function from its own entry: filters() from @dzgrid/dom/filters, pagination() from @dzgrid/dom/pagination, spans(), edit(), csvExport()… The base alone shows rows, sorts them, selects them and moves the focus; every other gesture comes with its feature. Every feature has its page under Features.

A feature that shows text needs its bundle merged into messages: without it, the grid is not made and a TypeError names the feature and the missing keys. A feature that draws more than the base usually has a sheet in @dzgrid/theme (menu.css, columns.css…). A setting or a column option that asks for a feature the grid lacks is told as a missing-feature problem, naming it.

The list is read once, when the grid is made: update() refuses a new one.

import { createGrid, type GridMessages } from '@dzgrid/dom';
import { filters } from '@dzgrid/dom/filters';
import { pagination } from '@dzgrid/dom/pagination';
import { EN } from '@dzgrid/dom/locales/en';
import { EN_FILTERS } from '@dzgrid/dom/locales/en-filters';
import { EN_PAGINATION } from '@dzgrid/dom/locales/en-pagination';
type Plant = { id: number; name: string; height: number };
const messages: GridMessages = { ...EN, text: { ...EN.text, ...EN_FILTERS.text, ...EN_PAGINATION.text } };
createGrid<Plant>(document.getElementById('plants')!, {
rows: [{ id: 1, name: 'Foxglove', height: 120 }],
columns: [{ id: 'name', header: 'Plant' }, { id: 'height', header: 'Height (cm)', type: 'number' }],
getRowId: (p) => p.id,
messages,
pagination: { pageSize: 25 },
features: [filters({ floating: true }), pagination()],
});