Users ask for the top rows, and the plugin sorts the table and selects the first rows in the order shown. The other rows stay, unless the question also names a condition: then the answer filters too, as in the third example.
select the top three by total
sort Total, largest firstselect the first 3 rowsselect the five newest orders
sort Placed, newest firstselect the first 5 rowsselect the two biggest orders from Germany
filter Country is Germanysort Total, largest firstselect the first 2 rowsRegister rowSelectionFeature, and leave enableRowSelection on (not false). The grouping setup registers it:
import { assistantGroupedRowModel } from '@gridsay/tanstack-table/react';import { columnGroupingFeature, createExpandedRowModel, rowExpandingFeature, rowSelectionFeature, tableFeatures,} from '@tanstack/react-table'; export const features = tableFeatures({ columnGroupingFeature, groupedRowModel: assistantGroupedRowModel(), rowExpandingFeature, expandedRowModel: createExpandedRowModel(), rowSelectionFeature,});Show the selection: highlight rows or check boxes bound to row.getIsSelected(). The quickstart's table gives selected rows a selected class for your styles.
Give rows a stable id from your data, so a selection stays on the same records when the data changes:
getRowId: (row) => row.id,TanStack's default row ids are positions.
The plugin selects among the rows your table holds. With paging on your server, it cannot reach rows that are not loaded, so "the top three" means the top three loaded rows. When the answer also changes a sort your server runs, the plugin selects from the rows loaded at that moment; it does not wait for your fetch. See Server-side data.
The plugin writes the selection state directly. A per-row enableRowSelection function is not consulted, so check permissions before you act on selected rows. Selected rows are not sent to Gridsay.
select: -1 without an error. The plugin leaves the existing selection alone.