Angular UI Components Documentation
This tutorial shows the two ways to give jqxGrid its rows in an Angular app: let the grid's data adapter load a URL, or load the data yourself, keep it in a signal, and hand it to the grid. You will also add and remove rows by changing that signal.
It is the first of a series of jqxGrid tutorials for Angular. Each one is a complete src/app/app.ts and src/app/app.html you can paste into a project and run.

You need an Angular CLI app with jqwidgets-ng installed and its stylesheets in angular.json, as set up in Angular CLI with jQWidgets. The examples were tested with Angular 22.2 and jqwidgets-ng 27.0.1, in a project made by ng new: standalone components, zoneless change detection, and the root component App in src/app/app.ts.
The examples use this sample file. Save it as public/products.json; the Angular CLI serves the public folder at the site root.
[
{
"id": 1,
"name": "Chai",
"category": "Beverages",
"price": 18,
"inStock": true
},
{
"id": 2,
"name": "Chang",
"category": "Condiments",
"price": 19,
"inStock": true
},
{
"id": 3,
"name": "Aniseed Syrup",
"category": "Confections",
"price": 10,
"inStock": false
},
{
"id": 4,
"name": "Ikura",
"category": "Dairy",
"price": 31,
"inStock": true
},
{
"id": 5,
"name": "Konbu",
"category": "Seafood",
"price": 6,
"inStock": true
},
{
"id": 6,
"name": "Tofu",
"category": "Beverages",
"price": 23.25,
"inStock": true
},
{
"id": 7,
"name": "Pavlova",
"category": "Condiments",
"price": 17.45,
"inStock": false
},
{
"id": 8,
"name": "Mascarpone",
"category": "Confections",
"price": 32,
"inStock": true
}
]
A jqx.dataAdapter describes where the rows come from and the type of each field. Given a url, it loads the rows itself when the grid binds to it. jqx is a global: importing jqxGridModule loads it, and jqwidgets-ng declares it for TypeScript.
src/app/app.ts:
import { Component } from '@angular/core';
import { jqxGridModule } from 'jqwidgets-ng/jqxgrid';
@Component({ selector: 'app-root', imports: [jqxGridModule], templateUrl: './app.html' })
export class App {
// The adapter loads the URL itself, when the grid binds to it.
readonly source = new jqx.dataAdapter(
{
url: '/products.json',
datatype: 'json',
id: 'id',
datafields: [
{ name: 'name', type: 'string' },
{ name: 'category', type: 'string' },
{ name: 'price', type: 'number' },
{ name: 'inStock', type: 'bool' }
]
},
{
loadError: (_xhr: XMLHttpRequest, status: string, error: string) => {
console.error('Loading the products failed:', status, error);
}
}
);
readonly columns: jqwidgets.GridColumn[] = [
{ text: 'Product', datafield: 'name', width: 220 },
{ text: 'Category', datafield: 'category', width: 160 },
{
text: 'Price',
datafield: 'price',
cellsformat: 'c2',
cellsalign: 'right',
align: 'right',
width: 110
},
{ text: 'In stock', datafield: 'inStock', columntype: 'checkbox', width: 90 }
];
}
src/app/app.html:
<jqxGrid
[theme]="'fluent'"
[width]="'100%'"
[autoheight]="true"
[source]="source"
[columns]="columns">
</jqxGrid>
The adapter and the columns are fields, created once with the component. The template binds them, and since they never change, the grid binds to its data once. The datafields types matter: a number field sorts and formats as a number (cellsformat: 'c2' writes it as currency), and a bool field fills the checkbox column. id: 'id' names the field that identifies a row, which methods such as updaterow and getrowdatabyid use.
The adapter sends the request with its own XMLHttpRequest. Angular's HttpClient is not involved, so HttpClient interceptors (for example one that adds an auth header) do not see it.
When the app needs the rows too (to count them, show them elsewhere, or change them), load them with HttpClient, keep them in a signal, and compute the adapter from the signal:
export class App {
private readonly http = inject(HttpClient);
readonly products = signal<Product[]>([]);
readonly error = signal<string | null>(null);
// A new data adapter whenever the rows change. The [source] input then changes, and the
// grid binds to the new rows.
readonly source = computed(
() =>
new jqx.dataAdapter({
localdata: this.products(),
datatype: 'array',
id: 'id',
datafields: [
{ name: 'id', type: 'number' },
{ name: 'name', type: 'string' },
{ name: 'category', type: 'string' },
{ name: 'price', type: 'number' },
{ name: 'inStock', type: 'bool' }
]
})
);
// …
}
export class App {
// …
constructor() {
// Load the rows once. takeUntilDestroyed cancels the request if the component is
// destroyed before the answer arrives.
this.http
.get<Product[]>('/products.json')
.pipe(takeUntilDestroyed())
.subscribe({
next: (rows) => this.products.set(rows),
error: (e: HttpErrorResponse) => this.error.set(e.message)
});
}
// …
}
In Angular 22 you can inject(HttpClient) without adding provideHttpClient() to app.config.ts; it sends its requests with fetch. takeUntilDestroyed() cancels the request if the component is destroyed before the answer arrives, and a failed request sets the error signal, which the template shows (for example Http failure response for http://localhost:4200/products.json: 404 Not Found).
The template binds the computed signal: [source]="source()". Each time products changes, source returns a new adapter, the [source] input changes, and the grid binds to the new rows.
fetch works as well. Cancel the request yourself when the component is destroyed, with DestroyRef:
export class App {
// …
constructor() {
// Load the rows once with fetch. The AbortController cancels the request if the
// component is destroyed before the answer arrives.
const controller = new AbortController();
inject(DestroyRef).onDestroy(() => controller.abort());
fetch('/products.json', { signal: controller.signal })
.then((response) => {
if (!response.ok) {
throw new Error(`HTTP ${response.status}`);
}
return response.json() as Promise<Product[]>;
})
.then((rows) => this.products.set(rows))
.catch((e: Error) => {
if (e.name !== 'AbortError') {
this.error.set(e.message);
}
});
}
// …
}
The callbacks of fetch run outside Angular's templates. The view still refreshes, because they set signals: in a zoneless app (the default for new Angular apps), a signal that a template reads is what tells Angular to update the view.
To add or remove rows, change the signal; the adapter and the grid follow. update starts from the current rows:
export class App {
// …
addProduct(): void {
this.products.update((current) => {
const id = Math.max(0, ...current.map((p) => p.id)) + 1;
return [...current, { id, name: `New product ${id}`, category: 'Beverages', price: 9.5, inStock: true }];
});
}
removeOutOfStock(): void {
this.products.update((current) => current.filter((p) => p.inStock));
}
}
A new source means a new binding: the grid shows the new rows, and drops its sort, filters and page. That is the right tool when the data set itself changes. To change a few values in rows the grid already shows, call the grid's own methods instead (setcellvalue, updaterow, addrow); Large data sets and live updates shows why that is much faster.
ng serve has no size limits, but ng build checks the budgets in angular.json. With the grid in the root component, the first bundle is about 2.2 MB, and the build of a new project stops with bundle initial exceeded maximum budget. Budget 1.00 MB was not met by 1.16 MB with a total of 2.16 MB. Raise the initial budget in the production configuration:
"budgets": [
{
"type": "initial",
"maximumWarning": "2.5MB",
"maximumError": "3MB"
},
{
"type": "anyComponentStyle",
"maximumWarning": "4kB",
"maximumError": "8kB"
}
],
Or load the part of the app that holds the grid lazily, with a route's loadComponent or a @defer block, so the grid's code is in a chunk of its own.
src/app/app.ts:
import { HttpClient, HttpErrorResponse } from '@angular/common/http';
import { Component, computed, inject, signal } from '@angular/core';
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
import { jqxGridModule } from 'jqwidgets-ng/jqxgrid';
export interface Product {
id: number;
name: string;
category: string;
price: number;
inStock: boolean;
}
@Component({ selector: 'app-root', imports: [jqxGridModule], templateUrl: './app.html' })
export class App {
private readonly http = inject(HttpClient);
readonly products = signal<Product[]>([]);
readonly error = signal<string | null>(null);
// A new data adapter whenever the rows change. The [source] input then changes, and the
// grid binds to the new rows.
readonly source = computed(
() =>
new jqx.dataAdapter({
localdata: this.products(),
datatype: 'array',
id: 'id',
datafields: [
{ name: 'id', type: 'number' },
{ name: 'name', type: 'string' },
{ name: 'category', type: 'string' },
{ name: 'price', type: 'number' },
{ name: 'inStock', type: 'bool' }
]
})
);
readonly columns: jqwidgets.GridColumn[] = [
{ text: 'Product', datafield: 'name', width: 220 },
{ text: 'Category', datafield: 'category', width: 160 },
{
text: 'Price',
datafield: 'price',
cellsformat: 'c2',
cellsalign: 'right',
align: 'right',
width: 110
},
{ text: 'In stock', datafield: 'inStock', columntype: 'checkbox', width: 90 }
];
constructor() {
// Load the rows once. takeUntilDestroyed cancels the request if the component is
// destroyed before the answer arrives.
this.http
.get<Product[]>('/products.json')
.pipe(takeUntilDestroyed())
.subscribe({
next: (rows) => this.products.set(rows),
error: (e: HttpErrorResponse) => this.error.set(e.message)
});
}
addProduct(): void {
this.products.update((current) => {
const id = Math.max(0, ...current.map((p) => p.id)) + 1;
return [
...current,
{ id, name: `New product ${id}`, category: 'Beverages', price: 9.5, inStock: true }
];
});
}
removeOutOfStock(): void {
this.products.update((current) => current.filter((p) => p.inStock));
}
}
src/app/app.html:
<h1>Products</h1>
@if (error(); as message) {
<p role="alert">Could not load the products: {{ message }}</p>
}
<p>
<button type="button" (click)="addProduct()">Add a product</button>
<button type="button" (click)="removeOutOfStock()">Remove products not in stock</button>
<span>{{ products().length }} products</span>
</p>
<jqxGrid
[theme]="'fluent'"
[width]="'100%'"
[autoheight]="true"
[source]="source()"
[columns]="columns">
</jqxGrid>
Run ng serve and open http://localhost:4200/. The grid shows the eight products; the buttons add a row and remove the products that are not in stock, and the count follows.