Users say which rows come first, and the plugin sets the table's sorting, on one column or several in order.
newest first
sort Placed, newest firstSort the tickets by priority, most urgent first
Tickets can't be sorted by priority in this grid.
Your user reads this sentence. The table stays as it was.In the second, the priority column keeps the developer's own urgency sortFn, so the assistant is told it cannot sort by it. The sentence is the assistant's own and varies: other recorded answers to the same question were "The Priority column can't be sorted in this grid." and "Sorting by priority is not allowed in this grid."
import { assistantColumn } from '@gridsay/tanstack-table';import { columnFilteringFeature, createColumnHelper, createFilteredRowModel, createSortedRowModel, rowSortingFeature, tableFeatures,} from '@tanstack/react-table'; type Order = { id: string; total: number; status: string; customer: string };export const features = tableFeatures({ columnFilteringFeature, filteredRowModel: createFilteredRowModel(), rowSortingFeature, sortedRowModel: createSortedRowModel(),});const helper = createColumnHelper<typeof features, Order>();export const columns = helper.columns([ helper.accessor('total', { header: 'Order total', meta: { assistant: { type: 'number', description: 'Order total in euros, including tax' } }, cell: (info) => `€${info.getValue().toFixed(2)}`, }), helper.accessor('status', { header: 'Status', meta: { assistant: { type: 'singleSelect', options: [ { value: 'paid', label: 'Paid' }, { value: 'refunded', label: 'Refunded' }, ], }, }, }), helper.accessor('customer', { header: 'Customer', meta: { assistant: { description: 'Customer display name', examples: ['Example company'] } }, }),]);export const defaultColumn = assistantColumn;rowSortingFeature and sortedRowModel registered in tableFeatures.assistantSort as the column's sortFn with sortUndefined: false, and no invertSorting. assistantColumn sets the first two.manualSorting: true, when your server sorts. Then the plugin only sets the sorting state; see Server-side data.assistantSort orders cells by the column's type:
| Type | Order |
|---|---|
number, boolean | By value. |
date, dateTime | By time. |
| Text and the rest | Alphabetically, in the browser's locale. |
Empty cells come first in ascending order and last in descending order. Rows that tie keep the order of your data. Group rows keep their order; the rows inside them are sorted.
An answer replaces the table's sorting. Every question also sends the current sorting, so a sort the user set by clicking a header goes with the next question, and a follow-up keeps it unless the user asks for another order.
enableSorting: false, or its own sortFn on a table that sorts in the browser.Each is declined: ask resolves false, the table stays as it was, and error.message is the assistant's sentence. A declined question is charged. See Refusals and errors.