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 widget sends it to a language model with a description of its columns, and applies the answer: here, a filter and a sort. The widgets can also answer questions about their data, write summaries, book free time and label rows.
This guide adds an AI command bar to a jqxGrid on a plain HTML page with jqwidgets-scripts 27.1.0, then does the same with jqxScheduler and jqxGantt. Your server holds the API key and calls the model. The pages use no jQuery: jqxcore.js provides $. With jQuery 3 or 4 on the page, they work the same.
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.Each AI module is a script of its own, loaded after its widget:
| Widget | AI scripts | AI methods |
|---|---|---|
| jqxGrid | jqxgrid.ai.js (it contains the shared transport) | aiCommand (filter, sort, group), aiAsk, aiSummarize, aiExplainRow, aiClassifyColumn |
| jqxScheduler | jqxwidgets.ai.js, then jqxscheduler.ai.js | aiCommand (search), aiScheduleAppointment, aiAsk, aiSummarize, aiExplainAppointment, aiClassifyAppointments, aiFindSlot, aiBookSlot, aiResolveConflicts, aiApplyResolution |
| jqxGantt | jqxwidgets.ai.js, then jqxgantt.ai.js | aiCommand (dates, progress, links), aiAddTask, aiAsk, aiSummarize, aiExplainTask, aiClassifyTasks |
The React and Vue Grid components and the Angular jqxGrid include the grid's AI module. In 27.1.0 the framework Scheduler and Gantt components do not load theirs. A React app can import the Scheduler's module itself: see AI features in React. This guide's Scheduler and Gantt pages are plain JavaScript.
The widget 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:
// 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 pages below call /api/ai on their own origin, so your web server passes /api/ requests on to port 3001, as a reverse proxy. The widget 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.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jqxGrid AI command bar</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/styles/jqx.fluent.css">
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxcore.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxdata.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxbuttons.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxscrollbar.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxmenu.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxlistbox.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxdropdownlist.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgrid.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgrid.selection.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgrid.sort.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgrid.filter.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgrid.grouping.js"></script>
<!-- the grid's AI module: aiCommand, aiAsk, aiSummarize, aiExplainRow, aiClassifyColumn -->
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgrid.ai.js"></script>
</head>
<body>
<form id="ask">
<input id="question" size="60" value="Orders from Germany over 1,000, largest first" aria-label="Ask the grid">
<button type="submit">Apply</button>
</form>
<p id="applied"></p>
<div id="grid"></div>
<script>
const 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 }
];
const adapter = new $.jqx.dataAdapter({
localdata: orders,
datatype: 'array',
datafields: [
{ name: 'customer', type: 'string' },
{ name: 'country', type: 'string' },
{ name: 'amount', type: 'number' }
]
});
$('#grid').jqxGrid({
theme: 'fluent',
width: '100%',
source: adapter,
sortable: true,
filterable: true,
groupable: true,
columns: [
{ text: 'Customer', datafield: 'customer' },
{ text: 'Country', datafield: 'country', width: 160 },
{ text: 'Amount', datafield: 'amount', width: 140, cellsalign: 'right', cellsformat: 'c2' }
],
// Production: send the grid's prompt to your own server, which holds the API key and calls
// the model. (For a quick local trial instead: aiProvider: 'anthropic' or 'openai' and aiKey.)
aiSendRequest: async ({ system, user }) => {
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;
}
});
// 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; the model's text never runs as code.
document.getElementById('ask').addEventListener('submit', (event) => {
event.preventDefault();
$('#grid').jqxGrid('aiCommand', document.getElementById('question').value, (error, result) => {
document.getElementById('applied').textContent = error ? error.message : 'Applied: ' + result.applied.join(', ');
});
});
</script>
</body>
</html>
aiSendRequest is called with { system, user } and returns the model's text. No key is in the page.$('#grid').jqxGrid('aiCommand', text) returns a Promise. The example uses the other form: a Node-style callback (error, result) as the last argument.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, and their scripts are loaded.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: "Applied: Country EQUAL Germany, Amount GREATER_THAN 1000, sort by Amount desc". Try "group by country" or "customers starting with A".
The same endpoint answers questions about a schedule. This page asks with aiAsk and shows the answer.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jqxScheduler AI assistant</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/styles/jqx.fluent.css">
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxcore.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxbuttons.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxscrollbar.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxdata.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxdate.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxscheduler.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxscheduler.api.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxdatetimeinput.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxmenu.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxcalendar.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxtooltip.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxwindow.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxcheckbox.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxlistbox.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxdropdownlist.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxnumberinput.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxradiobutton.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxinput.js"></script>
<!-- the shared AI transport, then the Scheduler's AI module -->
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxwidgets.ai.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxscheduler.ai.js"></script>
</head>
<body>
<form id="ask">
<input id="question" size="60" value="What is booked on Friday?" aria-label="Ask about the schedule">
<button type="submit">Ask</button>
</form>
<p id="answer" role="status"></p>
<div id="scheduler"></div>
<script>
const adapter = new $.jqx.dataAdapter({
localdata: [
{ id: '1', subject: 'Team standup', from: new Date(2026, 9, 12, 9, 0), to: new Date(2026, 9, 12, 9, 30) },
{ id: '2', subject: 'Design review', from: new Date(2026, 9, 13, 14, 0), to: new Date(2026, 9, 13, 15, 30) },
{ id: '3', subject: 'Customer call', from: new Date(2026, 9, 16, 10, 0), to: new Date(2026, 9, 16, 11, 0) }
],
datatype: 'array',
id: 'id',
datafields: [
{ name: 'id', type: 'string' },
{ name: 'subject', type: 'string' },
{ name: 'from', type: 'date' },
{ name: 'to', type: 'date' }
]
});
$('#scheduler').jqxScheduler({
theme: 'fluent',
width: '100%',
height: 500,
date: new $.jqx.date(2026, 10, 12),
source: adapter,
view: 'weekView',
views: ['dayView', 'weekView'],
appointmentDataFields: { id: 'id', subject: 'subject', from: 'from', to: 'to' },
// the same endpoint as the grid: your server holds the key
aiSendRequest: async ({ system, user }) => {
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;
}
});
document.getElementById('ask').addEventListener('submit', async (event) => {
event.preventDefault();
const answer = document.getElementById('answer');
try {
const result = await $('#scheduler').jqxScheduler('aiAsk', document.getElementById('question').value);
answer.textContent = result.answer;
} catch (error) {
answer.textContent = error.message;
}
});
</script>
</body>
</html>
A question such as "What is booked on Friday?" goes to the model with the appointments, and the answer appears above the scheduler. The other methods are called the same way:
aiScheduleAppointment(text) adds an appointment described in words, after it checks the subject and the times.aiFindSlot(text) resolves with { slots }: free times computed from the real appointments. aiBookSlot(slot, { subject }) books one of them.aiResolveConflicts() finds double bookings and proposes new times, without a model. aiApplyResolution(proposals) moves them, as one step for undo().Changes go through addAppointment and the scheduler's change events, so an appointmentAdding or appointmentChanging handler can still cancel them.
jqxGantt is created with new jqxGantt(selector, options), and its methods are called on that object. Its aiCommand changes task dates and progress and links tasks.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>jqxGantt AI commands</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/styles/jqx.base.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/styles/gantt/jqx.gantt.css">
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxcore.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgantt.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgantt.api.js"></script>
<!-- the shared AI transport, then the Gantt's AI module -->
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxwidgets.ai.js"></script>
<script src="https://cdn.jsdelivr.net/npm/jqwidgets-scripts@27.1.0/jqwidgets/jqxgantt.ai.js"></script>
</head>
<body>
<form id="ask">
<input id="question" size="60" value="Mark Design as done" aria-label="Change the plan">
<button type="submit">Apply</button>
</form>
<p id="applied" role="status"></p>
<div id="gantt"></div>
<script>
const gantt = new jqxGantt('#gantt', {
// full date-times: a date-only string would be read as UTC midnight
source: [
{ id: 'design', label: 'Design', dateStart: '2026-11-02T00:00:00', dateEnd: '2026-11-13T00:00:00', progress: 40, type: 'task' },
{ id: 'build', label: 'Build', dateStart: '2026-11-16T00:00:00', dateEnd: '2026-12-11T00:00:00', progress: 0, type: 'task' },
{ id: 'launch', label: 'Launch', dateStart: '2026-12-14T00:00:00', dateEnd: '2026-12-14T00:00:00', type: 'milestone' }
],
aiSendRequest: async ({ system, user }) => {
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;
}
});
// The model answers with task edits as JSON. Each one must name a task that exists,
// and dates and progress are checked before updateTask applies them.
document.getElementById('ask').addEventListener('submit', async (event) => {
event.preventDefault();
const applied = document.getElementById('applied');
try {
const result = await gantt.aiCommand(document.getElementById('question').value);
applied.textContent = 'Applied: ' + result.applied.join(', ');
} catch (error) {
applied.textContent = error.message;
}
});
</script>
</body>
</html>
"Mark Design as done" comes back as an edit of the task design with progress 100. The Gantt applies an edit only to a task whose id or label matches exactly one task, keeps progress between 0 and 100, and ignores an end date before the start. "Applied: "Design" progress=100" is shown above the chart.
Every AI method returns a Promise, except aiConfig, aiBookSlot and aiApplyResolution. The methods that return a Promise also take an optional Node-style callback (error, result) as their last argument.
| Method | What it does | Result |
|---|---|---|
| jqxGrid | ||
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 } |
| jqxScheduler | ||
aiCommand(text) | Shows only the appointments that match filters on subject, location, description, resource and status, and a date range. Resources and statuses must be ones the scheduler knows. | { spec, applied, query } |
aiScheduleAppointment(text) | Adds one appointment. It needs a subject and an end after the start. | { appointment, query } |
aiAsk(text) | Answers a question about the appointments. | { answer, query } |
aiSummarize() | Summarizes the selected appointment, or else up to aiMaxRows visible appointments. | { summary, count } |
aiExplainAppointment(key) | Explains how one appointment fits the schedule. | { key, explanation } |
aiClassifyAppointments({ datafield, instruction?, categories? }) | Writes a label into a property of your own (not a built-in field such as subject) of each appointment. | { datafield, written } |
aiFindSlot(text) | Reads the duration, resource, time window and working hours from the request, then computes free times. | { slots, query, request, subject }; each slot is { from, to, resourceId } |
aiBookSlot(slot, details?) | Adds an appointment in a slot from aiFindSlot. Throws when an appointmentAdding handler cancels it. | the appointment |
aiResolveConflicts(options?) | Finds overlapping appointments of the same resource and proposes the next free time for the later one. No model is called. | { conflicts, proposals } |
aiApplyResolution(proposals) | Moves the appointments as proposed, as one undo step. | the number moved |
| jqxGantt | ||
aiCommand(text) | Changes start and end dates and progress, and adds connections, for tasks named by id or label. | { spec, applied, query } |
aiAddTask(text) | Inserts a task, a project or a milestone, optionally inside an existing project. | { task, query } |
aiAsk(text) | Answers a question about the plan. | { answer, query } |
aiSummarize() | Summarizes progress, dates and overdue tasks. | { summary, count } |
aiExplainTask(ref) | Explains one task with its connections. | { ref, explanation } |
aiClassifyTasks({ datafield, instruction?, categories? }) | Writes a label into a field of your own on each task. Read it back with aiGetCustomField(ref, field). | { datafield, written } |
| All three | ||
aiConfig(options) | Sets or changes the AI configuration while the page runs. | the configuration |
Set them with the other widget options, or later with aiConfig({ ... }), which takes the keys in the second column: $('#grid').jqxGrid('aiConfig', { maxRows: 20 }).
| Option | 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 widget 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 widget 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, appointments or tasks are sent as context (default 40) |
The grid also has aiUrl, an older name for aiProxyUrl.
Each widget raises an event when an AI method has finished, and another when a request fails. The result is { type, result }, where type names the method ('command', 'ask', 'summary' and so on). An error is { error, message }.
| Widget | Events | Where the data is |
|---|---|---|
| jqxGrid | gridaiResult, gridaiError | the handler's second argument: $('#grid').on('gridaiResult', (event, data) => { ... }) |
| jqxScheduler | scheduleraiResult, scheduleraiError | event.args, as in the scheduler's other events |
| jqxGantt | ganttaiResult, ganttaiError | the handler's second argument, as for the grid |
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 widget, the scripts each one needs, and working examples.
The demos use an offline mock in place of the model, so they run without a key. Next: Grid getting started.