Skip to content

rowClass

Classes on a row from what it holds — a late order, a row to check — for your CSS to style.

Type(c: RowClassContext<T>) => string | null | undefined
Defaultnot set
Live update (update())Yes
Angularthe [rowClass] input
<dz-grid>the settings property: el.settings = { rowClass: … }
Declared inpackages/dom/src/settings.ts

A function given { row, key, context, pinned } that returns class names, separated by spaces, or null for none. They go on the row’s element, next to the grid’s own .dzg-row; pinned says 'top' or 'bottom' for a pinned row and is absent in the body. context is the grid’s context.

The grid asks again when a row is drawn with other data: another row in the same place while scrolling, a change to the row, the columns, the language, the context. Keep the same function from one update() to the next: a new one — an arrow written inline in a template — draws every row again. A class names a look; the colours stay CSS variables, so a dark theme and forced colours still apply.

import { createGrid } from '@dzgrid/dom';
import { EN } from '@dzgrid/dom/locales/en';
type Order = { id: string; client: string; daysLate: number };
createGrid<Order>(document.getElementById('orders')!, {
rows: [{ id: 'o1', client: 'Blue Mill', daysLate: 3 }],
columns: [{ id: 'client', header: 'Client' }, { id: 'daysLate', header: 'Days late', type: 'number' }],
getRowId: (o) => o.id,
messages: EN,
rowClass: ({ row }) => (row.daysLate > 0 ? 'late' : null),
});
/* The row and its pinned parts: each paints its own background. */
.dzg-row.late,
.dzg-row.late :is(.dzg-seg-start, .dzg-seg-end) {
background: color-mix(in srgb, var(--tz-warning) 14%, var(--tz-bg));
}