@gridsay/mui-x-data-grid gives you createPromptResolver, which replaces MUI's stock resolver as the grid's onPrompt. It tells Gridsay what your grid looks like now and what it allows, and checks every answer before the grid applies it.
It works behind your own server route and from the browser with a publishable key. It is MIT licensed, and its only dependency is @gridsay/core.
npm install @gridsay/mui-x-data-gridIt needs @mui/x-data-grid-premium 9.18 or a later 9.x release, and your own MUI X Premium licence. Other major versions are not tested.
Behind the route from the quickstart, the grid's component changes: onPrompt moves inside it and comes from createPromptResolver, kept between renders with useMemo, and the grid gets an apiRef from useGridApiRef(). The whole component:
'use client'; import { createPromptResolver } from '@gridsay/mui-x-data-grid';import { DataGridPremium, type DataGridPremiumProps, GridAiAssistantPanel, useGridApiRef,} from '@mui/x-data-grid-premium';import { useMemo } from 'react'; type Props = Pick<DataGridPremiumProps, 'rows' | 'columns'>; export function OrdersGrid({ rows, columns }: Props) { const apiRef = useGridApiRef(); const onPrompt = useMemo( () => createPromptResolver({ url: '/api/ai-assistant', apiRef }), [apiRef], ); return ( <DataGridPremium apiRef={apiRef} rows={rows} columns={columns} aiAssistant onPrompt={onPrompt} slots={{ aiAssistantPanel: GridAiAssistantPanel }} showToolbar /> );}The route stays as it is: the helper posts the same body MUI's resolver posts, with one more field, grid. To call Gridsay from the browser instead, pass the gateway's full prompt URL with a publishableKey and getToken: see From the browser.
Pass the grid's apiRef, the same one you give DataGridPremium, whenever you can. Without it the helper still checks answers and turns failures into readable sentences, but it cannot describe your grid or adapt answers to it.
Create one resolver per grid and keep it between renders, as useMemo does above. The resolver keeps the queue of questions for its grid.
| MUI's stock resolver | createPromptResolver with apiRef | |
|---|---|---|
| What Gridsay sees | The question and your column definitions | Also the features you switched off, each column's limits, option labels, and the current filters, sorting, grouping, totals and pivot |
| Changes made by hand | Unknown: a follow-up builds on the last answer | Seen: a follow-up builds on what the grid shows now |
| A feature your grid has switched off | Gridsay does not know the switch, so an answer can ask for it | The question is declined with a sentence |
| A malformed or cut-off answer | Not checked by Gridsay; the user can see a browser error | Refused before the grid changes; the user reads a short sentence |
| A question typed while one is running | Sent at once | Waits for the previous answer, so a follow-up builds on it |
| "Top 5 by rating" | Can fail when fewer rows exist than asked for, or they span pages | Selects the rows that exist after filtering and sorting, across pages |
| Sorting a grouped column | Sorts the column; group headers keep their order | Reorders the groups |
| Leaving pivot mode | The grouping and totals from before the pivot can come back | The new answer is what stays |
| A chart follow-up | The chart can bring back an older aggregation | Keeps the aggregation the answer asked for |
With apiRef, each question carries the grid's current view. Gridsay uses it, not the conversation's last answer, as the starting point. If the user removed a filter by hand, "now sort by salary" sorts without bringing the filter back. The view is sent even in private mode, where no conversation is kept.
The helper reads every response before the grid sees it. An answer with a missing field, a wrong type, an incomplete pivot or an aggregation function the grid does not have is rejected, and the grid stays as it was. The user reads a short sentence; you get a code: see Refusals and errors.
A question sent while another is running waits for the answer, and for the helper's own changes to the grid, before it is sent. A question typed before the first answer of a new conversation joins that conversation.
disableRowGrouping, rowSelection and dataSource are not in MUI's public API. The helper reads them from the grid's internal props, tested with 9.18. If a later version moves them, the helper treats every feature as switched on.dataSource, "top N" selects at most the rows of the loaded page.sum, avg, min, max and size, and option lists computed from a row.headers or getToken.The question, your column definitions and, with apiRef, the switches, column limits, option lists and the current filters, sorting, grouping, totals and pivot. Current filter values and option labels can contain your data. No whole rows are sent; example values from your rows go only if you turn on allowAiAssistantDataSampling or write them into your columns.