@gridkitjs/react v0.8.0
Minor Changes#
-
6e8189b: Aggregates: compute a subtotal per group and a grand total over the whole filtered/grouped dataset.
<DataGridComponent columns={columns} dataSource={rows} groupableColumns defaultGroupBy={[{ columnId: "Region" }]} aggregates={[{ columnId: "Amount", fn: "sum" }]} />;aggregatesis a plain controlled prop —AggregateState<Row>, an array of{ columnId, fn, id?, alignment? }specs. Unlikesort/filter/groupBy/pagination, there is no built-in UI to add or remove an aggregate interactively, so there's nodefaultAggregates/onAggregatesChangepair.groupAggregateDisplaychooses how a group's own subtotal renders:"inline"(the default) keeps it as text in the group header, next to its leaf-row count;"row"instead renders a dedicated row after that group's last visible entry, with each aggregate's value in the<td>for its own column, aligned the same way the grand-total footer's cells are.- A footer or
"row"-mode summary cell aligns the same way its column's own data cells do, unlessAggregateSpec.alignmentoverrides it for that specific aggregate — e.g. centering acountunder an otherwise right-aligned currency column. When two specs share a column and disagree, the first one inaggregateswins for that shared cell. - A grand-total footer (a
<tfoot>, outsidearia-rowcount) renders below the body wheneveraggregatesis non-empty, regardless ofgroupAggregateDisplay. ColumnDefinition.footerTemplaterenders a column's own aggregate result in place of its plain formatted value, in the grand-total footer and — undergroupAggregateDisplay: "row"— a group's own summary row.- A group's summary row is presentational: it occupies a real row slot (
aria-rowindexcounts it, same as a header or data row) but the arrow keys step over it rather than landing a tab stop there, and it never splits from its own group across a page boundary. - Aggregates are always computed over the full dataset, never scoped to the current page — composed ahead of pagination in the render pipeline, so a group's subtotal reads identically regardless of which page currently shows it.
DataGridApigainsgetAggregates()for the grand total; a specific group's own results are read offgetDisplayRows(), which now returns rows carrying a populatedaggregatesfield.
Depends on
@gridkitjs/core's new aggregate primitives (computeAggregates/withGroupAggregates) — see that package's own changelog entry, including the additiveaggregatesfield it adds toResolvedGroupRow. -
6e8189b:
pager.template— a render prop that replaces the built-in pager's markup entirely, called on every render where pagination-relevant state changed. Also exports the newPagerTemplateContexttype. As a side effect,pager={{ template: () => null }}is now the documented way to suppress the built-in pager while keepingpaginatedrow-windowing and the imperative API active — previously there was no way to do that short of turningpaginatedoff entirely. -
6e8189b: Opt-in numbered pager:
pager={{ variant: "numbered" }}swaps the built-in pager's "Page X of Y" display for[Prev][1][2][3]…[n][Next]page buttons.pager.boundaryCount(default1) andpager.siblingCount(default1) control how many pages are always shown at each end and around the current page. Default stays"compact"— today's Prev/status/Next — so no existing consumer's rendered output changes. -
6e8189b:
DataGridProps.pageSizeOptionsis now grouped under apagerconfig object, so future pager presentation options (a variant, a custom template) can land without another breaking rename:<DataGridComponent paginated - pageSizeOptions={[10, 25, 50]} + pager={{ sizeOptions: [10, 25, 50] }} />; -
6e8189b: Pagination: split the grid's rows into pages, respecting group boundaries.
<DataGridComponent columns={columns} dataSource={rows} paginated defaultPagination={{ pageIndex: 0, pageSize: 25 }} pager={{ sizeOptions: [10, 25, 50] }} onPaginationChange={({ pagination }) => persist(pagination)} />;paginatedturns pagination on;defaultPagination/onPaginationChangeare the uncontrolled page/page-size pair and its change callback, mirroringdefaultColumnSort/onColumnSortChange. Pagination always composes after filtering, sorting, and grouping — a page is a window onto the finished result. When grouping is also active, a page's unit is a top-level group, never a leaf row, so a group is never split across a page boundary.- Turning
paginatedon renders a minimal, semantically-classed pager below the grid (Previous/Next, a page display, and — withpager.sizeOptions— a page-size select). Style it via@gridkitjs/theme-tailwindor your own CSS. DataGridApigainsgetPagination(),getPageCount(),goToPage(),nextPage(),previousPage(), andsetPageSize().- Filtering, sorting, or changing the group-by stack resets to the first page, so a user is never silently stranded on a page a smaller result set no longer has.
Depends on
@gridkitjs/core's new pagination primitives (paginateRowsand friends) — see that package's own changelog entry, including thedatasetIndexfield this adds toResolvedRow/ResolvedGroupRow/CellTemplateContext.Breaking:
aria-rowindexon a rendered row is now built from that row's absolute dataset position rather than its rendered position — the two only diverge oncepaginatedis on, but the change applies unconditionally.GridGroupRow's exported prop shape (if consumed directly, which is not the supported path) dropsrowIndexin favor ofdatasetIndex. -
6e8189b:
DataGridApigainssubscribe(listener), a read/notify channel for reacting to grid state without polling the imperative getters — not a second, imperative-only way to drive that state. It's the primitive the newuse*Statehooks (added in following changes) are built on withuseSyncExternalStore; most consumers should reach for one of those instead of callingsubscribedirectly. -
6e8189b: New
useAggregateState(gridRef)hook: the grand-total aggregate results, read reactively off a mountedDataGridComponent'sref, for a summary footer or bar living outside the grid's own DOM. Read-only, and updates even on changes with no dedicatedon*Changeprop of their own — a filter/sort/regroup altering the grand total. -
6e8189b: New
useColumnSizingState(gridRef)anduseColumnOrderState(gridRef)hooks: column widths and column order, read reactively off a mountedDataGridComponent'sref. Read-only — sizing and order stay uncontrolled viadefaultColumnSizing/defaultColumnOrderand the grid's own resize/reorder handles. -
6e8189b: New
useColumnSortState(gridRef)hook: the grid's active sort, read reactively off a mountedDataGridComponent'sref, for a sort indicator living outside the grid's own DOM. Read-only —DataGridApihas no sort-mutating action. -
6e8189b: New
useGroupByState(gridRef)hook: reactive group-by and group-expansion state read off a mountedDataGridComponent'sref, withexpandAllGroups/collapseAllGroupsactions, for a custom group-by UI living outside the grid's own DOM. -
6e8189b: New
usePaginationState(gridRef)hook: reactive pagination state and actions (goToPage,nextPage,previousPage,setPageSize) read off a mountedDataGridComponent'sref, for building a pager entirely outside the grid's own DOM. Updates on every pagination change, including the silent page-0 reset a filter/sort/regroup triggers. -
6e8189b: New
useSelectionState(gridRef)hook: row, column, and cell selection read together as one reactive concern off a mountedDataGridComponent'sref, withclearSelection/selectAllRowsactions, for a "N rows selected" toolbar living outside the grid's own DOM.
Patch Changes#
- Updated dependencies [6e8189b]
- Updated dependencies [6e8189b]
- Updated dependencies [6e8189b]
- @gridkitjs/core@0.9.0