Skip to content

injectStyles

For a page whose Content Security Policy forbids <style> elements it did not write.

Typeboolean
Defaulttrue
Live update (update())No — read once, when the grid is made
Angularthe [injectStyles] input
<dz-grid>the settings property: el.settings = { injectStyles: … }
Declared inpackages/dom/src/settings.ts

The grid needs a few layout rules to work at all: rows placed absolutely, sticky headers and pinned columns. By default it writes them itself, once per document or shadow root, in a <style> element — and so does each feature with layout of its own (filters, pages, the status bar…). A policy that allows them with a nonce: give it with nonce and keep the default.

false: neither the grid nor its features write any <style>, your page loads the rules instead — except the date panels, whose own sheets are written unless the page already holds them under the same data-tzslot ids. The base’s are LAYOUT_CSS from @dzgrid/dom, in the dzgrid.layout layer; every feature with layout of its own exports it from its entry, named on its page (FILTERS_CSS, PAGINATION_CSS, STATUS_CSS, TREE_CSS…). The look itself, @dzgrid/theme, is always yours to load. The setting is read once: update() refuses a change.

import { createGrid } from '@dzgrid/dom';
import { EN } from '@dzgrid/dom/locales/en';
type Log = { id: string; message: string; level: number };
createGrid<Log>(document.getElementById('logs')!, {
rows: [{ id: 'l1', message: 'Pump started', level: 1 }],
columns: [{ id: 'message', header: 'Message' }, { id: 'level', header: 'Level', type: 'number' }],
getRowId: (l) => l.id,
messages: EN,
injectStyles: false,
});
/* Built into your own stylesheet, e.g. from LAYOUT_CSS at build time. */
@layer dzgrid.layout { /* … the grid's layout rules … */ }