Skip to content
MUI’s hosted AI Assistant backend shuts down at the end of 2026.Switch in two lines →
  • Products
    • AG Grid AI Toolkit Early accessThe model and the server behind the toolkit.
    • MUI X Data Grid StableThe backend for the Premium AI Assistant.
    • TanStack Table Public alphaA plugin that applies each answer to your table.
    • AG Studio Early accessA hosted backend for its assistant, not built yet.
  • How it works
  • Accuracy
  • Pricing
  • Security
  • Docs
    • Quickstart: server route
    • Quickstart: TanStack Table
    • Browser keys
    • Moving from MUI’s hosted service
    • Guide: when MUI’s service retires
Sign inStart a 7-day trial
Menu
  • Products
    • AG Grid AI Toolkit Early access
    • MUI X Data Grid Stable
    • TanStack Table Public alpha
    • AG Studio Early access
  • How it works
  • Accuracy
  • Pricing
  • Security
  • Docs
    • Quickstart: server route
    • Quickstart: TanStack Table
    • Browser keys
    • Moving from MUI’s hosted service
    • Guide: when MUI’s service retires
  • Sign in

Product

  • How it works
  • Accuracy
  • Pricing
  • Data and security

Grids

  • AG Grid AI ToolkitEarly access
  • MUI X Data Grid PremiumStable
  • TanStack TablePublic alpha
  • AG StudioEarly access

Docs

  • Quickstart: server route
  • Browser keys
  • Guide: when MUI’s service retires

Company

  • Contact
  • Terms
  • Privacy

Not affiliated with or endorsed by MUI or AG Grid. MUI and AG Grid are trademarks of their respective owners.

© 2026 Gridsay

Docs pages
Start
  • Documentation
  • How it works
  • Examples
MUI X Data Grid
  • Quickstart: server route
  • From the browser
  • Using the helper
  • Filtering
  • Sorting
  • Grouping
  • Aggregation
  • Pivoting
  • Charts
  • Row selection
  • Follow-up questions
  • Refusals and errors
  • Moving from MUI’s service
  • Reference
TanStack Table
  • Quickstart
  • Describing columns
  • Filtering
  • Sorting
  • Grouping
  • Row selection
  • Server-side data
  • Controlled state
  • Undo and reset
  • Refusals and errors
  • API reference
Keys and sign-in
  • Secret and publishable keys
  • Browser keys
  • JWT and OIDC
  • Session tokens
  • Identity webhook
  • Per-user limits
  • The console
  • Data and privacy
HTTP API
  • HTTP API
  • Authentication
  • Data Grid endpoint
  • Follow-up questions
  • Private mode
Reference
  • Errors
  • Limits
  • Tiers and credits
  • @gridsay/core
On this page

On this page

  1. Sorting kept in React state
  2. Show the answer within one second
  3. What an answer changes
  4. Follow-ups read the current state
  5. Next
Skip to the article
Start
  • Documentation
  • How it works
  • Examples
MUI X Data Grid
  • Quickstart: server route
  • From the browser
  • Using the helper
  • Filtering
  • Sorting
  • Grouping
  • Aggregation
  • Pivoting
  • Charts
  • Row selection
  • Follow-up questions
  • Refusals and errors
  • Moving from MUI’s service
  • Reference
TanStack Table
  • Quickstart
  • Describing columns
  • Filtering
  • Sorting
  • Grouping
  • Row selection
  • Server-side data
  • Controlled state
  • Undo and reset
  • Refusals and errors
  • API reference
Keys and sign-in
  • Secret and publishable keys
  • Browser keys
  • JWT and OIDC
  • Session tokens
  • Identity webhook
  • Per-user limits
  • The console
  • Data and privacy
HTTP API
  • HTTP API
  • Authentication
  • Data Grid endpoint
  • Follow-up questions
  • Private mode
Reference
  • Errors
  • Limits
  • Tiers and credits
  • @gridsay/core

Controlled state

On this page

  1. Sorting kept in React state
  2. Show the answer within one second
  3. What an answer changes
  4. Follow-ups read the current state
  5. Next

You can keep sorting, filters, grouping or selection in your own state. The plugin changes them through the table's setters, so your handlers must take the update and show it.

Sorting kept in React state#

TSX
'use client'; import { assistantColumn, useTableAssistant } from '@gridsay/tanstack-table/react';import {  createColumnHelper,  createSortedRowModel,  rowSortingFeature,  type SortingState,  tableFeatures,  useTable,} from '@tanstack/react-table';import { useState } from 'react'; type Order = { id: string; total: number };const features = tableFeatures({  rowSortingFeature,  sortedRowModel: createSortedRowModel(),});const helper = createColumnHelper<typeof features, Order>();const columns = helper.columns([helper.accessor('total', { header: 'Order total' })]); export function ControlledOrders({ data }: { data: Order[] }) {  const [sorting, setSorting] = useState<SortingState>([]);  const table = useTable({    features,    columns,    data,    getRowId: (row) => row.id,    defaultColumn: assistantColumn,    state: { sorting },    onSortingChange: setSorting,  });  const { ask, undo, reset, canUndo, pending, error } = useTableAssistant(table, {    url: '/api/tanstack-table',  });  return (    <>      <button disabled={pending} type="button" onClick={() => void ask('Largest orders first')}>        Largest first      </button>      <button disabled={pending || !canUndo} type="button" onClick={() => undo()}>Undo</button>      <button type="button" onClick={reset}>New conversation</button>      {error ? <p role="alert">{error.message}</p> : null}      <ol>{table.getRowModel().rows.map((row) => <li key={row.id}>{String(row.getValue('total'))}</li>)}</ol>    </>  );}

This table registers sorting only, so filter and group questions are declined. It posts to the route from the quickstart.

Show the answer within one second#

After it writes an answer, the plugin waits up to one second for the table's state to show it. Update the state at once; if your rows come from a server, fetch after.

  • If the state does not show the answer in time, ask fails with cannot_apply, and the plugin puts the earlier state back.
  • If a setter throws, ask fails with cannot_apply too.
  • Gridsay has already answered, so the question is charged. Fix the handler before asking again.

The plugin can put the earlier state back only through your setters. A handler that ignores every write keeps whatever it holds.

What an answer changes#

StateWhen it changes
columnFiltersWhen it changesReplaced when filtering is on, including filters set by hand.
globalFilterWhen it changesCleared when filtering is on and the table has a global filter.
sortingWhen it changesReplaced when sorting is on.
groupingWhen it changesReplaced when grouping is on.
rowSelectionWhen it changesReplaced when the answer selects rows; otherwise left alone.
pagination, expandedWhen it changesNot written by an answer. TanStack's auto-reset settings may change them; undo puts them back.

Column visibility, order, pinning and sizes never change.

Follow-ups read the current state#

Each question sends the current sorting and grouping, including a header click, and the filters an earlier answer set. Questions go one at a time, so a follow-up reads the table after the previous answer is on it.

Keep one hook per table. The conversation and the answer to undo last as long as the component stays mounted. The hook reads the latest table and options for every question, so a new getToken or url takes effect on the next one.

Next#

  • Undo and reset
  • Server-side data
  • Refusals and errors