Angular UI Components Documentation
The jQWidgets Grid, Scheduler and Gantt have AI modules. A user types a request in plain English, such as "orders from Germany over 1,000, largest first". The component sends it to a language model with a description of its columns, and applies the answer: here, a filter and a sort. The components can also answer questions about their data, write summaries and label rows.
This guide adds an AI command bar to a jqxGrid in a project made with Angular CLI 22 (ng new) and jqwidgets-ng 27.1.0. Your server holds the API key and calls the model. The project setup is described in Angular CLI with jQWidgets.
addfilter, sortby, addAppointment, updateTask). Nothing in the answer is run as code.aiFindSlot asks the model only what the user wants ("30 minutes before Friday afternoon"). The free slots come from the real appointments. aiResolveConflicts calls no model at all.aiSendRequest, the component calls your function and your function calls your server. The browser never sees the key.aiCommand sends the request and the column names and types, not the data. aiAsk and aiSummarize add up to aiMaxRows rows (40 by default), and aiAsk and aiExplainRow add the minimum, maximum, sum, average and count of each number column. aiExplainRow also sends its row, and aiClassifyColumn sends every row, with the fields you name in sourceFields. The Scheduler and the Gantt send up to aiMaxRows appointments or tasks. Your server sees each request and can remove what must not be sent.| Component | AI methods | In Angular (jqwidgets-ng 27.1.0) |
|---|---|---|
| Grid | aiCommand (filter, sort, group), aiAsk, aiSummarize, aiExplainRow, aiClassifyColumn | Included in jqxGridComponent. Bind [aiSendRequest] and call the methods through viewChild. |
| Scheduler | aiCommand (search), aiScheduleAppointment, aiAsk, aiSummarize, aiExplainAppointment, aiClassifyAppointments, aiFindSlot, aiBookSlot, aiResolveConflicts, aiApplyResolution | jqxSchedulerComponent does not load this AI module. The methods work in plain JavaScript: see AI features in JavaScript. |
| Gantt | aiCommand (dates, progress, links), aiAddTask, aiAsk, aiSummarize, aiExplainTask, aiClassifyTasks | jqxGanttComponent does not load this AI module either. The methods work in plain JavaScript. |
The component builds two texts: system (the instructions and the columns) and user (the request and, for questions, the data). This server sends them to the Anthropic Messages API with your key and returns the model's text. It runs on Node 18 or later and needs no packages.
server.mjs, next to the project:
// server.mjs - the /api/ai endpoint for aiSendRequest (Node 18+, no dependencies).
// The API key stays here, on the server. Run: ANTHROPIC_API_KEY=... node server.mjs
import http from 'node:http';
http.createServer(async (req, res) => {
if (req.method !== 'POST' || req.url !== '/api/ai') {
res.writeHead(404).end();
return;
}
let body = '';
for await (const chunk of req) body += chunk;
const { system, user } = JSON.parse(body);
const reply = await fetch('https://api.anthropic.com/v1/messages', {
method: 'POST',
headers: {
'content-type': 'application/json',
'x-api-key': process.env.ANTHROPIC_API_KEY,
'anthropic-version': '2026-05-28'
},
body: JSON.stringify({
model: 'claude-sonnet-5-5',
max_tokens: 1024,
system,
messages: [{ role: 'user', content: user }]
})
});
const json = await reply.json();
const text = (json.content || []).filter(part => part.type === 'text').map(part => part.text).join('');
res.writeHead(reply.ok ? 200 : 502, { 'content-type': 'application/json' });
res.end(JSON.stringify(reply.ok ? { text } : { error: json.error?.message || 'model error' }));
}).listen(3001);
Start it with your key in the environment:
ANTHROPIC_API_KEY=your-key node server.mjs
The component only needs text back, so the server can call any provider or a model you host. Before you deploy it, check the user's session in the endpoint and limit how often it can be called: anyone who can reach /api/ai can spend your tokens.
The app calls /api/ai on its own origin. In development, ng serve passes those requests on to server.mjs with a proxy configuration. In production, your web server or reverse proxy does the same.
proxy.conf.json, in the project folder:
{
"/api": {
"target": "http://localhost:3001",
"secure": false
}
}
This function is what the components call. It receives { system, user } and returns the model's text.
src/app/ai.ts:
// The components send their prompt here. Your server adds the API key and calls the model.
export async function sendRequest({ system, user }: { system: string; user: string }): Promise<string> {
const response = await fetch('/api/ai', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ system, user })
});
if (!response.ok) {
throw new Error('AI request failed: ' + response.status);
}
return (await response.json()).text;
}
ng add jqwidgets-ng put jqx.base.css into the styles of angular.json. Add the theme after it:
"styles": [
"./node_modules/jqwidgets-ng/jqwidgets/styles/jqx.base.css",
"./node_modules/jqwidgets-ng/jqwidgets/styles/jqx.fluent.css",
"src/styles.css"
]
src/app/app.ts:
import { Component, signal, viewChild } from '@angular/core';
import { jqxGridComponent, jqxGridModule } from 'jqwidgets-ng/jqxgrid';
import { sendRequest } from './ai';
@Component({ selector: 'app-root', imports: [jqxGridModule], templateUrl: './app.html' })
export class App {
readonly grid = viewChild.required<jqxGridComponent>('grid');
readonly status = signal('');
// The grid calls this function with its prompt (see ai.ts).
readonly sendRequest = sendRequest;
readonly orders = [
{ customer: 'Alfreds Futterkiste', country: 'Germany', amount: 1250 },
{ customer: 'Bon app', country: 'France', amount: 480 },
{ customer: 'Ernst Handel', country: 'Austria', amount: 2310 },
{ customer: 'Folk och fä', country: 'Sweden', amount: 925 },
{ customer: 'Königlich Essen', country: 'Germany', amount: 1780 },
{ customer: 'Lehmanns Marktstand', country: 'Germany', amount: 640 },
{ customer: 'Rattlesnake Canyon', country: 'USA', amount: 3120 }
];
// jqx is a global declared by jqwidgets-ng.
readonly source = new jqx.dataAdapter({
localdata: this.orders,
datatype: 'array',
datafields: [
{ name: 'customer', type: 'string' },
{ name: 'country', type: 'string' },
{ name: 'amount', type: 'number' }
]
});
readonly columns: jqwidgets.GridColumn[] = [
{ text: 'Customer', datafield: 'customer' },
{ text: 'Country', datafield: 'country', width: 160 },
{ text: 'Amount', datafield: 'amount', width: 140, cellsalign: 'right', cellsformat: 'c2' }
];
async apply(event: Event, question: string): Promise<void> {
event.preventDefault();
this.status.set('Asking the model...');
try {
// The model answers with filters, a sort and groups as JSON. The grid checks them
// against its real columns and operators and applies only those.
const result: { applied: string[] } = await this.grid().aiCommand(question);
this.status.set('Applied: ' + result.applied.join(', '));
} catch (error) {
this.status.set((error as Error).message);
}
}
}
src/app/app.html:
<form (submit)="apply($event, question.value)">
<input #question value="Orders from Germany over 1,000, largest first" size="60" aria-label="Ask the grid">
<button type="submit">Apply</button>
</form>
<p role="status">{{ status() }}</p>
<jqxGrid #grid
[theme]="'fluent'"
[width]="'100%'"
[source]="source"
[columns]="columns"
[sortable]="true"
[filterable]="true"
[groupable]="true"
[aiSendRequest]="sendRequest">
</jqxGrid>
[aiSendRequest]="sendRequest" connects the grid to your server. No key is in the app.aiCommand is called through viewChild. It returns a Promise, which resolves when the actions are applied, or rejects when the request fails.result.applied lists the actions as text. Show it, so the user sees what the grid did with the request.filterable, sortable and groupable allow them.Keep server.mjs running, and start the app with the proxy in a second terminal:
ng serve --proxy-config proxy.conf.json
Click Apply. The model returns a filter on Country, a filter on Amount and a sort, and the grid shows the two German orders over 1,000, largest first. The line above the grid reads, for example, "Applied: Country EQUAL Germany, Amount GREATER_THAN 1000, sort by Amount desc". Try "group by country" or "customers starting with A".
Every AI method returns a Promise. It also takes an optional Node-style callback (error, result) as its last argument.
| Method | What it does | Resolves with |
|---|---|---|
aiCommand(text) | Turns a request into filters, a sort and groups, checks them against the columns and operators, and applies them. The model can also ask to clear the current filters and groups first. | { spec, applied, query }: the model's JSON, the applied actions as text, the request |
aiAsk(text) | Answers a question from the columns, the totals of the number columns and up to aiMaxRows rows. | { answer, chart, query }; chart is a suggested chart ({ type, categoryField, valueField, aggregate }) or null |
aiSummarize(rows?) | Summarizes the rows you pass, or else the selected rows, or else up to aiMaxRows rows. | { summary, count } |
aiExplainRow(rowindex) | Explains how one row compares with the rest of the data. | { row, explanation } |
aiClassifyColumn({ datafield, instruction, categories?, sourceFields? }) | Asks for one label per row and writes it into the existing column datafield with setcellvalue. | { datafield, written } |
aiConfig(options) | Sets or changes the AI configuration while the app runs. | the configuration (not a Promise) |
Bind them as inputs, or set them through viewChild with aiConfig({ ... }), which takes the keys in the second column.
| Input | aiConfig key | Meaning |
|---|---|---|
aiSendRequest | sendRequest | async ({ system, user, model, provider }) => string. Your own transport. When it is set, the options below that describe a provider are not used. |
aiProxyUrl | proxyUrl | Your endpoint. The component posts the provider's request body there (Anthropic or OpenAI format, by aiProvider) and reads the provider's response. |
aiProvider | provider | 'anthropic' (default), 'openai' or 'custom' (the Anthropic format) |
aiKey | apiKey | The provider's API key, for a trial on your own machine only: it is visible to anyone who opens the page. |
aiModel | model | The model name. Without it, the component uses claude-opus-4-8 (Anthropic) or gpt-4o (OpenAI). |
aiHeaders | headers | Extra request headers, for example your session token for aiProxyUrl |
aiMaxRows | maxRows | How many rows are sent as context (default 40) |
The grid also has aiUrl, an older name for aiProxyUrl. String inputs need quotes inside the binding: [aiProvider]="'openai'".
| Output | Raised |
|---|---|
(onGridaiResult) | after an AI method has finished |
(onGridaiError) | when a request fails |
In jqwidgets-ng 27.1.0 the component emits only the event object, without the result or the error. Read both from the Promise of the method, as the example does.
jqxChat is a chat interface, inline or as a floating button, with streamed replies and your own branding. It connects in the same way: provider and apiKey for a trial, proxyUrl or sendRequest to go through your server. Its sendRequest receives the whole conversation in the provider's request format. See Chat getting started.
The features above are for your users. For you, the jQWidgets MCP server gives AI coding assistants (Claude Code, Cursor, GitHub Copilot) the API of every component, the scripts each one needs, and working examples.
The demos are JavaScript pages. They use an offline mock in place of the model, so they run without a key. Next: Grid getting started.