Vue 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 Vue which task to open. It also shows how to keep text that users typed from being read as HTML.

Use a Vite and Vue 3 app set up as in Add a Grid to a Vue 3 app.
A column's cellsrenderer returns the HTML of the cell. It returns a string, not a Vue component or template: the grid draws its cells itself, for speed. Anything that comes from users, such as a task title, goes through an escaping function first.
That applies to columns without a renderer as well. In jqwidgets-scripts 27.1.0 and earlier the grid writes a cell's value into the page as HTML, so a value such as <b>bold</b> in a plain text column shows in bold, and an <img> with an onerror attribute runs its script. The grid's enableSanitize option stops the script but shows such a value escaped twice. The example therefore gives every column of user text, the task and its owner, a renderer that escapes it. The third task has <script> in its title and shows it as text.
// Cell renderers return HTML. Data 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]!);
}
// The grid writes values as HTML in columns without a renderer too, so every column of user
// text gets this one.
const textCell = (_row: number, _field: string, value: unknown) =>
`<div class="text-cell">${escapeHtml(String(value))}</div>`;
A renderer replaces the cell's content, including the element the grid puts around the value for alignment and padding. The text-cell class gives the text back its padding, and a line height equal to the grid's rowsheight (40 pixels here) centres it vertically.
The badge, the progress bar and the due date are styled in a stylesheet. Save it as src/tasks.css; the component imports it. It has to be a global stylesheet: a <style scoped> block only reaches the elements Vue renders from the template, and the cells' HTML is written by the grid.
.text-cell { 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: #7c3aed; }
.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.
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.
The click calls openTask, a function of the component, which sets a ref. Vue's reactivity does not depend on where the call comes from, so the message under the grid follows, even though the button was made by the grid's code. The button column refers to openTask, and the columns are made once, with the component:
// The task an Open button chose, shown under the grid.
const opened = shallowRef<Task | null>(null);
function openTask(id: number) {
opened.value = tasks.find((t) => t.id === id) ?? null;
}
const columns = [
{ text: 'Task', datafield: 'title', width: 240, cellsrenderer: textCell },
{ text: 'Owner', datafield: 'owner', width: 90, cellsrenderer: textCell },
{
text: 'Status', datafield: 'status', width: 110,
cellsrenderer: (_row: number, _field: string, value: Task['status']) =>
`<span class="status ${statusClass[value]}">${escapeHtml(value)}</span>`
},
{
text: 'Progress', datafield: 'progress', width: 130,
cellsrenderer: (_row: number, _field: string, value: number) =>
`<div class="progress" role="progressbar" aria-valuenow="${value}" aria-valuemin="0" aria-valuemax="100"><div style="width: ${Number(value)}%"></div><span>${Number(value)}%</span></div>`
},
{
text: 'Due', datafield: 'due', width: 100, 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: 80, columntype: 'template',
// A real button in the cell. createwidget runs once per visible row element; the grid
// reuses those elements as it scrolls, and initwidget points them at their new row.
createwidget: (_row: unknown, _column: unknown, value: number, cellElement: HTMLElement) => {
const button = document.createElement('button');
button.type = 'button';
button.className = 'open-task';
button.textContent = 'Open';
button.dataset.id = String(value);
button.addEventListener('click', () => openTask(Number(button.dataset.id)));
cellElement.appendChild(button);
},
initwidget: (_row: unknown, _column: unknown, value: number, cellElement: HTMLElement) => {
const button = cellElement.querySelector('button');
if (button) {
button.dataset.id = String(value);
}
}
}
];
The message is written with {{ }}, which escapes text: the third task's title shows as text there too.
<script setup lang="ts">
import { shallowRef } from 'vue';
import JqxGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxgrid.vue';
import './tasks.css';
// Defined globally by the jQWidgets core, which the Grid component imports.
declare const jqx: any;
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. Data 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]!);
}
// The grid writes values as HTML in columns without a renderer too, so every column of user
// text gets this one.
const textCell = (_row: number, _field: string, value: unknown) =>
`<div class="text-cell">${escapeHtml(String(value))}</div>`;
const statusClass: Record<Task['status'], string> = {
Open: 'status-open',
'In progress': 'status-progress',
Blocked: 'status-blocked',
Done: 'status-done'
};
const 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 task an Open button chose, shown under the grid.
const opened = shallowRef<Task | null>(null);
function openTask(id: number) {
opened.value = tasks.find((t) => t.id === id) ?? null;
}
const columns = [
{ text: 'Task', datafield: 'title', width: 240, cellsrenderer: textCell },
{ text: 'Owner', datafield: 'owner', width: 90, cellsrenderer: textCell },
{
text: 'Status', datafield: 'status', width: 110,
cellsrenderer: (_row: number, _field: string, value: Task['status']) =>
`<span class="status ${statusClass[value]}">${escapeHtml(value)}</span>`
},
{
text: 'Progress', datafield: 'progress', width: 130,
cellsrenderer: (_row: number, _field: string, value: number) =>
`<div class="progress" role="progressbar" aria-valuenow="${value}" aria-valuemin="0" aria-valuemax="100"><div style="width: ${Number(value)}%"></div><span>${Number(value)}%</span></div>`
},
{
text: 'Due', datafield: 'due', width: 100, 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: 80, columntype: 'template',
// A real button in the cell. createwidget runs once per visible row element; the grid
// reuses those elements as it scrolls, and initwidget points them at their new row.
createwidget: (_row: unknown, _column: unknown, value: number, cellElement: HTMLElement) => {
const button = document.createElement('button');
button.type = 'button';
button.className = 'open-task';
button.textContent = 'Open';
button.dataset.id = String(value);
button.addEventListener('click', () => openTask(Number(button.dataset.id)));
cellElement.appendChild(button);
},
initwidget: (_row: unknown, _column: unknown, value: number, cellElement: HTMLElement) => {
const button = cellElement.querySelector('button');
if (button) {
button.dataset.id = String(value);
}
}
}
];
</script>
<template>
<main style="padding: 16px">
<h1>Tasks</h1>
<JqxGrid width="100%" :autoheight="true" :rowsheight="40" theme="material-purple" :source="source" :columns="columns" />
<p aria-live="polite">{{ opened ? `Opened "${opened.title}" (${opened.owner})` : 'Open a task to see it here.' }}</p>
</main>
</template>
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 ref.