Skip to content

pagination

The rows one page at a time, rather than one long scrolling list.

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

pageSize: the rows on a page, 50 by default. pageSizes: the sizes the pager offers, [25, 50, 100] by default; the current size is added when the list lacks it. Each must be a whole number from 1: anything else is told (invalid-page) and the default taken.

With browser rows, the setting turns pages on: each page is a cut of the filtered, sorted rows. With a source, the server sends one page per request. The pagination() feature from @dzgrid/dom/pagination draws the pager under the rows — first, previous, « Page 2 of 5 », next, last, and the size list — with its texts -pagination; without it, the pages still work from code (page.go, page.size) and a missing-feature warning says the pager is missing. The setting is read once: update() refuses a change.

import { createGrid } from '@dzgrid/dom';
import { pagination } from '@dzgrid/dom/pagination';
import { EN } from '@dzgrid/dom/locales/en';
import { EN_PAGINATION } from '@dzgrid/dom/locales/en-pagination';
type Shell = { id: string; name: string; beach: string };
const rows: Shell[] = Array.from({ length: 230 }, (_, i) => ({ id: `s${i}`, name: `Shell ${i + 1}`, beach: i % 2 ? 'North' : 'South' }));
createGrid<Shell>(document.getElementById('shells')!, {
rows,
columns: [{ id: 'name', header: 'Shell' }, { id: 'beach', header: 'Beach' }],
getRowId: (s) => s.id,
messages: { ...EN, text: { ...EN.text, ...EN_PAGINATION.text } },
pagination: { pageSize: 50, pageSizes: [25, 50, 100] },
features: [pagination()],
});

Five rows a page; the pager under the rows.