DataGrid remote data

Remote Data

Bind the current server page while the parent component owns fetching, loading state, and total count.

Remote binding is the right model when the dataset is too large for the browser, the backend owns filtering or sorting, or permissions require every page to come from an API.

Use the grid pager to request another server page. Showing 0 row(s) from [total]="23".

Loading interactive DataGrid example…

Code snippet

      import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { ColumnDef, Datagrid } from '@angular-bootstrap/ngbootstrap';

@Component({
  standalone: true,
  imports: [Datagrid],
  template: `
    <ngb-datagrid
      [columns]="columns"
      [data]="orders"
      [loading]="loading"
      [total]="total"
      [pageable]="{ pageSizes: [25, 50], info: true }"
      [pageSize]="pageSize"
      (pageChange)="loadPage($event.page, $event.pageSize)"
    />
  `,
})
export class RemoteOrdersPage {
  orders: Order[] = [];
  total = 0;
  pageSize = 25;
  loading = false;

  constructor(private readonly http: HttpClient) {}

  loadPage(page: number, pageSize: number): void {
    this.loading = true;
    this.http
      .get<{ items: Order[]; total: number }>('/api/orders', { params: { page, pageSize } })
      .subscribe((result) => {
        this.orders = result.items;
        this.total = result.total;
        this.loading = false;
      });
  }
}
    

API information

APITypeUsage
[data]T[]Provides only the current server page when remote binding is active.
[total]number | nullTells the pager the full server-side result count, even when only one page is loaded.
[loading]booleanShows the grid loading overlay and sets aria-busy while the request is in progress.
(pageChange)EventEmitter<{ page: number; pageSize: number }>Emits when the user changes page or page size so the parent can request a new server page.
[pageable]boolean | NgbDatagridPageableSettingsEnables paging controls for the remote result set.
[pageSize]numberKeeps the grid pager and API request page size in sync.

This project is not affiliated with ng-bootstrap or ngx-bootstrap. Those projects focus mainly on Bootstrap components for Angular. ngbootstrap focuses on Angular UI for data-heavy apps, especially Data Grid, Angular-native Form Builder, drag and drop workflows, documentation examples, and performance-focused Angular patterns.