Global Configuration
provideGridDefaults() sets what every grid in the app starts from, so a grid you add later is already dressed like the rest. A per-grid config still wins — key by key, so overriding one option keeps every other one.
What this site's own defaults look like
This grid sets no rowHeight and no pageSize. Both come from the provideGridDefaults() call in the demo's application config — the same one every other grid on the site inherits.
This grid's config is three lines, and none of them is about height or paging:
config = { height: 420, scrollMode: 'paging', sortMode: 'client' };
Its rows are 48px tall and it pages at 50, both from the
provideGridDefaults() call in this demo's own application config. Every other grid on
this site is reading the same two values — which is the point of setting them once: a grid you add
next month is already dressed like the rest, without anybody remembering to dress it.
Defaults are a floor, not a lock. Anything you set on a grid still wins, which is
the second example. The reverse holds too: a key you never set anywhere falls through to the
library's own default, so provideGridDefaults() is somewhere to put the handful of
decisions your product has actually made, and nothing more.
A per-grid config wins — one key at a time
The same grid with one line added: rowHeight: 32. The rows are shorter and nothing else moved — the page size is still the app-wide 50, because the merge is per key rather than all-or-nothing.
The same three lines, plus one:
config = { height: 420, scrollMode: 'paging', sortMode: 'client',
rowHeight: 32 };
The rows are shorter, and nothing else changed. Look at the pager under each
grid: both report the same number of pages, because both are still using the app-wide
pageSize: 50. That is what "merged key by key" means — overriding one option is not
opting out of the rest.
The same rule holds one level further in. config.messages merges key by key against
the app-wide messages rather than replacing them, so a grid that renames a single string keeps
every other translation. See Localisation.
provideGridDefaults()
Call once in ApplicationConfig.providers. Every <gridcraft>
in the app inherits these values. Per-grid [config] always takes precedence.
It accepts any GridConfig option — all 61 of them. But they do
not all combine with a grid's own [config] in the same way, and the difference is
worth knowing before you rely on it.
How a global value combines with a per-grid one
Three behaviours, and every option falls into exactly one of them.
1 · Combined option by option — messages and icons
These two combine key by key. Set the loading text globally and the empty text on one grid, and that grid shows both. Only the keys you repeat get overridden.
provideGridDefaults({ messages: { loading: 'Loading...', empty: 'Nothing here' } })
// This grid gets its own empty text and KEEPS the global loading text.
config = { messages: { empty: 'No employees match' } };
2 · Changeable while the app runs — dir, theme, messages
These three can also be swapped after the app has started, through
GridDirectionService below — for a language switcher or a dark-mode toggle. A
grid that sets the option itself keeps its own value and ignores the switch.
3 · Replaced completely — every other option
For the rest, a grid that sets the option at all replaces the global value entirely. For a plain
value like rowHeight that is exactly what you would expect. For an option that
holds a group of settings, it is the part that catches people out:
provideGridDefaults({
rowSelection: { mode: 'multi', checkboxColumn: false },
})
// This grid meant to change nothing but the mode - but the whole group is
// replaced, so checkboxColumn: false is gone and the checkbox column is back.
config = { rowSelection: { mode: 'single' } };
// Repeat what you want to keep:
config = { rowSelection: { mode: 'single', checkboxColumn: false } };
Only messages and icons combine option by option. For everything else,
a grid that sets a group of settings has to repeat the ones it wants to keep from the global
value — nothing warns you if it does not.
GridDirectionService
A root-level signal service. Calling setDir('rtl') and
setMessages({ records: 'سجل', loading: '...' }) updates all grids
that don't have an explicit per-grid override — no page refresh needed.
Whenever your app's active language changes — whether driven by a signal, a service, a URL
parameter, or any other mechanism — call setDir() and setMessages()
together. All grids update in the same tick. Click the button above to see it live.
effect(() => {
const l = lang();
gridLocale.setDir(RTL_LOCALES.has(l) ? 'rtl' : 'ltr');
gridLocale.setMessages(GRID_MESSAGES[l] ?? GRID_MESSAGES['en']);
});
Priority (highest wins)
- Per-grid
[config]="{ dir: 'rtl' }"— explicit override for one grid GridDirectionService.setDir()— reactive app-level directionprovideGridDefaults({ dir: '...' })— static app-level default'ltr'— built-in fallback
The same three levels apply to theme. Set a house theme once with
provideGridDefaults, switch it at runtime with
GridDirectionService.setTheme() for a dark-mode toggle, and let any single grid pin
its own theme with config.theme.
Global configuration API
| Property | Type | Default | Description |
|---|---|---|---|
| provideGridDefaults() | Partial<GridConfig> | — | Set once in ApplicationConfig.providers — every grid inherits these defaults; per-grid [config] always wins. |
| GridDirectionService.setDir() | (dir: 'ltr' | 'rtl') => void | — | Reactive app-level direction — updates every grid without an explicit per-grid override, no refresh. |
| GridDirectionService.setMessages() | (messages: GridMessages) => void | — | Swap the built-in UI strings at runtime, in the same tick as the direction change. |
| GridDirectionService.setTheme() | (theme: GridTheme) => void | — | Switch the theme for every grid at runtime — a grid with its own config.theme keeps it. |
| config.messages | Partial<GridMessages> | — | Combined option by option with the global value — override one label without repeating the rest. |
| config.icons | Partial<GridIconSet> | — | Combined option by option with the global value, the same way messages is. See Custom Icons. |
| GRID_MESSAGES | Record<string, GridMessages> | — | Shipped locale packs: en, ar, fr, de, es, pt, fa, ur, tr, zh, ja, ru. |
| RTL_LOCALES | Set<string> | — | Locale codes the library treats as right-to-left. |
| config.dir | 'ltr' | 'rtl' | 'ltr' | Explicit per-grid direction — highest priority, beats the service and the global default. |