DataGrid Pagination Settings
Tune the reusable ngb-pager settings used by the DataGrid footer, including button count, page size, and responsive layout.
Pagination
Pagination is a standalone feature: use ngb-pager with any data source, or ngb-pagination for buttons only. The datagrid wires ngb-pager through [pageable]. Adjust the controls below to see how each setting affects the live pager.
Settings playground
These map to NgbPagerSettings. The active pageSize is always included in the dropdown when it is not listed in pageSizes.
Standalone ngb-pager (full width)
Loading interactive example…
Responsive density — narrow container (≈400px, compact: hides info)
Loading interactive example…
Minimal density — very narrow (≈320px, hides info and page sizes)
Loading interactive example…
- ORD-1000 — Customer 1
- ORD-1001 — Customer 2
- ORD-1002 — Customer 3
- ORD-1003 — Customer 4
- ORD-1004 — Customer 5
Datagrid with [pageable]
Same settings object as standalone ngb-pager, plus position for top, bottom, or both footers. Pagination slices paged rows automatically.
Loading interactive DataGrid example…
Defaults
- NGB_PAGER_DEFAULT_SETTINGS
{"buttonCount":10,"info":true,"pageSizes":false,"previousNext":true,"type":"numeric","responsive":true}- NGB_PAGER_BREAKPOINTS
- full ≥ 520px · compact ≥ 360px · minimal below compact
NgbPagerSettings
| Property | Type | Default | Description |
|---|---|---|---|
buttonCount | number | 10 | Max numeric page buttons before ellipsis. |
info | boolean | true | Shows range label (e.g. 1–5 of 23) on the left. |
pageSizes | false | number[] | false | Rows-per-page dropdown options; false hides the control. |
previousNext | boolean | true | Shows previous/next controls. |
type | 'numeric' | 'input' | 'numeric' | Page buttons or page number input. |
responsive | boolean | true | Progressively hides info and page sizes when the container is narrow. |
NgbPagerComponent (ngb-pager)
| Input / Output | Type | Description |
|---|---|---|
page | number | Current page (1-based). |
pageSize | number | Items per page. |
collectionSize | number | Total item count across all pages. |
settings | boolean | NgbPagerSettings | null | true for defaults, or a settings object. |
infoLabel | string | Optional override for the range label when info is on. |
rangeLabelTemplate | string | Template with {start}, {end}, {total}. Default '1–5 of 6' style. |
rowsPerPageLabel | string | Label beside the page-size dropdown. Default Rows per page. |
responsive | boolean | Overrides settings.responsive when set. |
(pageChange) | EventEmitter<number> | Emits the new page index. |
(pageSizeChange) | EventEmitter<number> | Emits the new page size. |
NgbDatagridPageableSettings (datagrid [pageable])
Extends NgbPagerSettings with grid placement:
| Property | Type | Default | Description |
|---|---|---|---|
position | 'top' | 'bottom' | 'both' | 'bottom' | Where the built-in pager renders relative to the table. |
Pass [pageable]="true" for defaults, or an object to override. Legacy [enablePagination] + [pageSizeOptions] still activates pagination with preset page sizes.
NgbPaginationComponent (ngb-pagination)
Low-level control used inside ngb-pager. Use directly when you only need page buttons or a page input.
| Input / Output | Type | Description |
|---|---|---|
page | number | Current page (1-based). |
pageSize | number | Items per page. |
collectionSize | number | Total records. |
buttonCount | number | Visible page buttons (min 3). |
previousNext | boolean | Show « and » buttons. |
pagerType | 'numeric' | 'input' | Button list or page input. |
responsive | boolean | Allow pagination buttons to wrap inside the nav. |
(pageChange) | EventEmitter<number> | Emits when the user selects a page. |
Custom pager template
Project <ng-template ngbPager> inside ngb-datagrid. Responsive layout is disabled; you own the full footer UI. Context: page, pageSize, total, pageCount, grid.
@Component({
imports: [Datagrid, NgbPagerTemplate],
template: `
<ngb-datagrid [columns]="columns" [data]="rows" [pageable]="{ pageSizes: [10, 25] }">
<ng-template ngbPager let-ctx>
<div class="d-flex gap-2 align-items-center">
<button type="button" class="btn btn-sm btn-outline-secondary"
[disabled]="ctx.page <= 1" (click)="grid.onPage(ctx.page - 1)">Prev</button>
<span>Page {{ ctx.page }} / {{ ctx.pageCount }} ({{ ctx.total }} records)</span>
<button type="button" class="btn btn-sm btn-outline-secondary"
[disabled]="ctx.page >= ctx.pageCount" (click)="grid.onPage(ctx.page + 1)">Next</button>
</div>
</ng-template>
</ngb-datagrid>
`,
})
export class CustomPagerGrid {}
Pager settings (ngb-pager & datagrid pageable)
Integration steps
- Import NgbPagerComponent from @angular-bootstrap/ngbootstrap (or ngbootstrap/pagination) for any list, table, or custom grid.
- Bind [page], [pageSize], and [collectionSize]; pass [settings]="true" for defaults or an NgbPagerSettings object.
- Handle (pageChange) and (pageSizeChange) to update your data slice.
- On ngb-datagrid, use [pageable] with the same settings plus optional position: "top" | "bottom" | "both".
- Set pageSizes to a number array for the rows-per-page dropdown, or false to hide it.
- responsive: true (default) hides range info and page sizes as the footer narrows; false keeps all controls and wraps.
- Use <ng-template ngbPager> inside the grid for a fully custom pager (disables built-in responsive layout).
Datagrid with pageable
import { Datagrid, NgbDatagridPageableSettings } from '@angular-bootstrap/ngbootstrap';
@Component({
imports: [Datagrid],
template: `
<ngb-datagrid
[columns]="columns"
[data]="rows"
[pageSize]="pageSize"
[pageable]="pageable"
(pageChange)="onPageChange($event)"
></ngb-datagrid>
`,
})
export class OrdersGrid {
pageSize = 10;
readonly pageable: NgbDatagridPageableSettings = {
buttonCount: 5,
info: true,
pageSizes: [5, 10, 25, 50],
previousNext: true,
type: 'numeric',
responsive: true,
position: 'bottom',
};
onPageChange(event: { page: number; pageSize: number }): void {
this.pageSize = event.pageSize;
}
}
Standalone ngb-pager
import { NgbPagerComponent, NgbPagerSettings } from '@angular-bootstrap/ngbootstrap';
@Component({
imports: [NgbPagerComponent],
template: `
<ngb-pager
[page]="page"
[pageSize]="pageSize"
[collectionSize]="items.length"
[settings]="pagerSettings"
[infoLabel]="rangeLabel"
rowsPerPageLabel="Rows per page"
(pageChange)="page = $event"
(pageSizeChange)="onPageSize($event)"
/>
<ul>
<li *ngFor="let item of pagedItems">{{ item.name }}</li>
</ul>
`,
})
export class StandaloneListPager {
page = 1;
pageSize = 10;
readonly items = [/* your data */];
readonly pagerSettings: NgbPagerSettings = {
buttonCount: 5,
info: true,
pageSizes: [10, 25, 50],
previousNext: true,
type: 'numeric',
responsive: true,
};
get pagedItems() {
const start = (this.page - 1) * this.pageSize;
return this.items.slice(start, start + this.pageSize);
}
get rangeLabel(): string {
return `${(this.page - 1) * this.pageSize + 1}–${Math.min(this.page * this.pageSize, this.items.length)} of ${this.items.length}`;
}
onPageSize(size: number): void {
this.pageSize = size;
this.page = 1;
}
}