Vue 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 Vite project with Vue 3.5, TypeScript and jqwidgets-scripts 27.1.0. Your server holds the API key and calls the model. The project setup is described in Vite and Vue 3.
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 Vue (jqwidgets-scripts 27.1.0) |
|---|---|---|
| Grid | aiCommand (filter, sort, group), aiAsk, aiSummarize, aiExplainRow, aiClassifyColumn | Included in JqxGrid. Bind :aiSendRequest and call the methods through a template ref. |
| Scheduler | aiCommand (search), aiScheduleAppointment, aiAsk, aiSummarize, aiExplainAppointment, aiClassifyAppointments, aiFindSlot, aiBookSlot, aiResolveConflicts, aiApplyResolution | JqxScheduler 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 | JqxGantt 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, the Vite server passes those requests on to server.mjs. In production, your web server or reverse proxy does the same.
vite.config.ts:
import vue from '@vitejs/plugin-vue';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [vue()],
// In development, pass the app's /api requests to server.mjs.
server: { proxy: { '/api': 'http://localhost:3001' } }
});
This function is what the components call. It receives { system, user } and returns the model's text.
src/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;
}
src/main.ts loads the styles once:
import { createApp } from 'vue';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.base.css';
import 'jqwidgets-scripts/jqwidgets/styles/jqx.fluent.css';
import App from './App.vue';
createApp(App).mount('#app');
The components are .vue files without type declarations. Declare them once in src/jqwidgets-vue3.d.ts, or vue-tsc stops with TS7016:
// The Vue components are plain .vue files without types: declare them once for TypeScript.
declare module 'jqwidgets-scripts/jqwidgets-vue3/*.vue' {
import type { DefineComponent } from 'vue';
const component: DefineComponent<Record<string, any>, Record<string, any>, any>;
export default component;
}
src/App.vue:
<script setup lang="ts">
import { ref } from 'vue';
import JqxGrid from 'jqwidgets-scripts/jqwidgets-vue3/vue_jqxgrid.vue';
import { sendRequest } from './ai';
// Defined globally by jqxcore.js, which the component imports.
declare const jqx: any;
// The grid method this component calls, for the template ref. aiCommand resolves with
// the model's JSON and the actions the grid applied.
interface GridMethods {
aiCommand: (text: string) => Promise<{ applied: string[] }>;
}
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 }
];
// Constants, not refs: the grid binds to the adapter once.
const source = new jqx.dataAdapter({
localdata: orders,
datatype: 'array',
datafields: [
{ name: 'customer', type: 'string' },
{ name: 'country', type: 'string' },
{ name: 'amount', type: 'number' }
]
});
const columns = [
{ text: 'Customer', datafield: 'customer' },
{ text: 'Country', datafield: 'country', width: 160 },
{ text: 'Amount', datafield: 'amount', width: 140, cellsalign: 'right', cellsformat: 'c2' }
];
// Template ref: the name matches ref="grid" in the template.
const grid = ref<GridMethods | null>(null);
const question = ref('Orders from Germany over 1,000, largest first');
const status = ref('');
async function apply() {
status.value = '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 = await grid.value!.aiCommand(question.value);
status.value = 'Applied: ' + result.applied.join(', ');
} catch (error) {
status.value = (error as Error).message;
}
}
</script>
<template>
<form @submit.prevent="apply">
<input v-model="question" size="60" aria-label="Ask the grid" />
<button type="submit">Apply</button>
</form>
<p role="status">{{ status }}</p>
<JqxGrid
ref="grid"
theme="fluent"
width="100%"
:source="source"
:columns="columns"
:sortable="true"
:filterable="true"
:groupable="true"
:aiSendRequest="sendRequest"
/>
</template>
:aiSendRequest="sendRequest" connects the grid to your server. No key is in the app.aiCommand is called through the template ref. 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 in a second terminal:
npm run dev
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. Add the methods you call to the GridMethods interface.
| 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 props, or set them through the template ref with aiConfig({ ... }), which takes the keys in the second column.
| Prop | 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.
| Event | Raised |
|---|---|
@gridaiResult | after an AI method has finished |
@gridaiError | when a request fails |
In jqwidgets-scripts 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.