Skip to content

direction

Which way the grid reads: left to right, or right to left.

Type'auto' | 'ltr' | 'rtl'
Default'auto'
Live update (update())Yes
Angularthe [direction] input
<dz-grid>the direction attribute
Declared inpackages/dom/src/settings.ts

'auto' follows the direction the grid’s host is in — its nearest dir attribute, or the page’s — and its changes: switch <html dir> and the grid turns with it. 'ltr' and 'rtl' set it whatever the page says.

Everything turns with the direction: the columns’ order, the side pinned columns stick to, the scrolling, the arrow keys (→ still moves to the right, which in Arabic is toward the start of the line), popups, a tree’s indent, the theme’s lines and shadows. That is why the options speak of start and end, never of left and right: pinned: 'start' is on the right in right to left. A change keeps the horizontal scroll where it was, in the reading order.

import { createGrid } from '@dzgrid/dom';
import { AR } from '@dzgrid/dom/locales/ar';
type Souk = { id: string; name: string; stalls: number };
const grid = createGrid<Souk>(document.getElementById('souks')!, {
rows: [{ id: 's1', name: 'سوق النجوم', stalls: 48 }],
columns: [{ id: 'name', header: 'السوق', pinned: 'start' }, { id: 'stalls', header: 'الدكاكين', type: 'number' }],
getRowId: (s) => s.id,
messages: AR,
direction: 'rtl',
});
grid.update({ direction: 'auto' }); // follow the page instead

A grid in Arabic, live: Theming and right to left.