Skip to content

nonce

For a page whose Content Security Policy allows styles only with the nonce it gives.

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

The grid and its features write their layout rules in <style> elements. Under a policy such as style-src 'nonce-r4nd0m', the browser ignores a <style> without that nonce. Give the page’s nonce: the grid puts it on every <style> it writes, its features’ included, and the browser applies them.

The nonce is the server’s, new for each page served; the grid only passes it on. It is read once, when the grid is made: update() refuses a change. A policy that allows no <style> at all needs injectStyles: false instead.

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,
nonce: document.querySelector<HTMLMetaElement>('meta[name=csp-nonce]')?.content ?? '', // your server writes it in the page
});