Angular UI Components Documentation
This tutorial changes how cells look: a coloured badge for a task's status, a progress bar, a red due date when a task is late, and a button in each row that tells the component which task to open. It also shows how to keep text that users typed from being read as HTML, and where the styles for such cells go in an Angular app.

Use an Angular CLI app set up as in Angular CLI with jQWidgets.
A column's cellsrenderer returns the HTML of the cell. It returns a string, not an Angular template: the grid draws its cells itself, for speed, and Angular does not process that HTML. Anything that comes from users, such as a task title, therefore goes through an escaping function first. The third task in the example has <script> in its title, and shows it as text.
// Cell renderers return HTML. Text that users typed goes through escapeHtml first:
// the third task's title would otherwise be markup.
function escapeHtml(text: string): string {
return text.replace(/[&<>"']/g, (c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]!);
}
export class App {
// …
readonly columns: jqwidgets.GridColumn[] = [
{
text: 'Task', datafield: 'title', width: 260,
cellsrenderer: (_row, _field, value) => `<div class="task-title">${escapeHtml(String(value))}</div>`
},
{ text: 'Owner', datafield: 'owner', width: 100 },
{
text: 'Status', datafield: 'status', width: 120,
cellsrenderer: (_row, _field, value) => {
const status = value as Task['status'];
return `<span class="status ${statusClass[status]}">${escapeHtml(status)}</span>`;
}
},
{
text: 'Progress', datafield: 'progress', width: 150,
cellsrenderer: (_row, _field, value) =>
`<div class="progress" role="progressbar" aria-valuenow="${Number(value)}" aria-valuemin="0" aria-valuemax="100"><div style="width: ${Number(value)}%"></div><span>${Number(value)}%</span></div>`
},
// …
];
// …
}
The badge, the progress bar and the due date are styled with classes. In Angular, a component's own styles or styleUrl apply only to the elements of its template, and the cells are not: the grid creates them. A rule in the component's stylesheet does not reach them. Add the rules to src/styles.css, which applies to the whole page:
.task-title { padding: 0 6px; line-height: 40px; overflow: hidden; text-overflow: ellipsis; }
.status { display: inline-block; margin: 10px 6px; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-open { background: #e0e7ff; color: #3730a3; }
.status-progress { background: #fef3c7; color: #92400e; }
.status-blocked { background: #fee2e2; color: #991b1b; }
.status-done { background: #dcfce7; color: #166534; }
.progress { position: relative; height: 18px; margin: 11px 8px; border-radius: 9px; background: #e5e7eb; overflow: hidden; }
.progress > div { height: 100%; background: #93c5fd; }
.progress > span { position: absolute; inset: 0; text-align: center; font-size: 12px; line-height: 18px; color: #111827; }
.overdue { color: #b91c1c !important; font-weight: 600; }
.open-task { margin: 6px; padding: 4px 12px; cursor: pointer; }
cellclassname returns a class for one cell, from its value and its row. The due date of a task that is not done and is due before today gets the overdue class. Prefer it to a renderer when only the style changes: the grid keeps drawing and formatting the value itself.
export class App {
// …
readonly columns: jqwidgets.GridColumn[] = [
// …
{
text: 'Due', datafield: 'due', width: 110, cellsformat: 'yyyy-MM-dd',
// A class on the cell, from the row's data: overdue tasks that are not done.
cellclassname: (_row: number, _field: string, value: Date, rowdata: Task) =>
rowdata.status !== 'Done' && value < new Date(new Date().toDateString()) ? 'overdue' : ''
},
// …
];
// …
}
A column with columntype: 'template' holds elements you create. createwidget creates them, once for each row element the grid shows. The grid reuses those row elements as you scroll or page, and calls initwidget to point them at their new row. The button keeps the task's id in a data-id attribute for that reason, and reads it when it is clicked. (dataset['id'] is written with brackets because the CLI's tsconfig.json turns on noPropertyAccessFromIndexSignature.)
export class App {
// …
readonly columns: jqwidgets.GridColumn[] = [
// …
{
text: '', datafield: 'id', width: 90, columntype: 'template',
// A real button in the cell. createwidget runs once for each row element the grid
// shows; the grid reuses those elements as it scrolls or pages, and initwidget
// points them at their new row.
createwidget: (_row, _column, value, cellElement) => {
const button = document.createElement('button');
button.type = 'button';
button.className = 'open-task';
button.textContent = 'Open';
button.dataset['id'] = String(value);
button.addEventListener('click', () => this.open(Number(button.dataset['id'])));
cellElement.appendChild(button);
},
initwidget: (_row, _column, value, cellElement) => {
const button = cellElement.querySelector('button');
if (button) {
button.dataset['id'] = String(value);
}
}
}
];
// …
}
Two details make the click reach the component:
this is the component and this.open(…) works. A method handed over as is, such as cellsrenderer: this.renderTitle, runs without the component as this.open sets a signal. The click listener is not part of a template, and since Angular 22 components are OnPush by default: Angular refreshes the view because a signal it reads changed. A plain field set in that listener would not show, with or without zone.js.export class App {
// …
open(id: number): void {
this.opened.set(tasks.find((t) => t.id === id) ?? null);
}
}
src/app/app.ts:
import { Component, signal } from '@angular/core';
import { jqxGridModule } from 'jqwidgets-ng/jqxgrid';
interface Task {
id: number;
title: string;
owner: string;
status: 'Open' | 'In progress' | 'Blocked' | 'Done';
progress: number;
due: Date;
}
const tasks: Task[] = [
{
id: 1,
title: 'Design the onboarding flow',
owner: 'Nancy',
status: 'Done',
progress: 100,
due: new Date(2026, 8, 12)
},
{
id: 2,
title: 'Migrate billing to the new API',
owner: 'Andrew',
status: 'In progress',
progress: 65,
due: new Date(2026, 9, 3)
},
{
id: 3,
title: 'Fix <script> injection in comments',
owner: 'Janet',
status: 'Blocked',
progress: 20,
due: new Date(2026, 9, 1)
},
{
id: 4,
title: 'Write the release notes',
owner: 'Margaret',
status: 'Open',
progress: 0,
due: new Date(2026, 9, 20)
},
{
id: 5,
title: 'Load-test the search service',
owner: 'Steven',
status: 'In progress',
progress: 40,
due: new Date(2026, 9, 9)
},
{
id: 6,
title: 'Accessibility audit',
owner: 'Michael',
status: 'Open',
progress: 10,
due: new Date(2026, 10, 2)
}
];
// Cell renderers return HTML. Text that users typed goes through escapeHtml first:
// the third task's title would otherwise be markup.
function escapeHtml(text: string): string {
return text.replace(
/[&<>"']/g,
(c) => ({ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' })[c]!
);
}
const statusClass: Record<Task['status'], string> = {
Open: 'status-open',
'In progress': 'status-progress',
Blocked: 'status-blocked',
Done: 'status-done'
};
@Component({ selector: 'app-root', imports: [jqxGridModule], templateUrl: './app.html' })
export class App {
// Updated from a click in the grid. The grid calls that code itself, outside Angular's
// templates, so the view refreshes because a signal changed.
readonly opened = signal<Task | null>(null);
readonly source = new jqx.dataAdapter({
localdata: tasks,
datatype: 'array',
id: 'id',
datafields: [
{ name: 'id', type: 'number' },
{ name: 'title', type: 'string' },
{ name: 'owner', type: 'string' },
{ name: 'status', type: 'string' },
{ name: 'progress', type: 'number' },
{ name: 'due', type: 'date' }
]
});
// The callbacks are arrow functions: the grid calls them, and an arrow function keeps
// the component as `this`.
readonly columns: jqwidgets.GridColumn[] = [
{
text: 'Task',
datafield: 'title',
width: 260,
cellsrenderer: (_row, _field, value) =>
`<div class="task-title">${escapeHtml(String(value))}</div>`
},
{ text: 'Owner', datafield: 'owner', width: 100 },
{
text: 'Status',
datafield: 'status',
width: 120,
cellsrenderer: (_row, _field, value) => {
const status = value as Task['status'];
return `<span class="status ${statusClass[status]}">${escapeHtml(status)}</span>`;
}
},
{
text: 'Progress',
datafield: 'progress',
width: 150,
cellsrenderer: (_row, _field, value) =>
`<div class="progress" role="progressbar" aria-valuenow="${Number(value)}" aria-valuemin="0" aria-valuemax="100"><div style="width: ${Number(value)}%"></div><span>${Number(value)}%</span></div>`
},
{
text: 'Due',
datafield: 'due',
width: 110,
cellsformat: 'yyyy-MM-dd',
// A class on the cell, from the row's data: overdue tasks that are not done.
cellclassname: (_row: number, _field: string, value: Date, rowdata: Task) =>
rowdata.status !== 'Done' && value < new Date(new Date().toDateString())
? 'overdue'
: ''
},
{
text: '',
datafield: 'id',
width: 90,
columntype: 'template',
// A real button in the cell. createwidget runs once for each row element the grid
// shows; the grid reuses those elements as it scrolls or pages, and initwidget
// points them at their new row.
createwidget: (_row, _column, value, cellElement) => {
const button = document.createElement('button');
button.type = 'button';
button.className = 'open-task';
button.textContent = 'Open';
button.dataset['id'] = String(value);
button.addEventListener('click', () => this.open(Number(button.dataset['id'])));
cellElement.appendChild(button);
},
initwidget: (_row, _column, value, cellElement) => {
const button = cellElement.querySelector('button');
if (button) {
button.dataset['id'] = String(value);
}
}
}
];
open(id: number): void {
this.opened.set(tasks.find((t) => t.id === id) ?? null);
}
}
src/app/app.html:
<h1>Tasks</h1>
<jqxGrid
[theme]="'fluent'"
[width]="'100%'"
[autoheight]="true"
[rowsheight]="40"
[source]="source"
[columns]="columns">
</jqxGrid>
<p aria-live="polite">
@if (opened(); as task) {
Opened "{{ task.title }}" ({{ task.owner }})
} @else {
Open a task to see it here.
}
</p>
The grid shows a badge for each status, a progress bar, and the due dates of late tasks in red. Open on a row writes that task under the grid, from the signal: Opened "Migrate billing to the new API" (Andrew). Angular's {{ }} interpolation escapes text itself, so the third task's title shows as text there too.