@gridkitjs/react v0.10.0
Minor Changes#
-
6af35c6: Columns can be shown and hidden. A column with
hidden: truestarts out hidden;defaultColumnVisibility(column id →true/false) overrides that per column, and the ref'sshowColumns(ids)/hideColumns(ids)change it afterwards. A hidden column still sorts, filters and groups, and keeps its place in the column order for when it is shown again.onColumnVisibilityChangefires once per change with{ columnIds, visibility }.DataGridApigainsgetColumnVisibility()andgetDataColumns()(every column, hidden ones included);getColumns()lists only what is shown.useColumnVisibilityState(gridRef)follows the visibility state from outside the grid.aria-colcount, the column widths and keyboard column moves count only the columns shown; a group header or group-by chip for a hidden column keeps its label.
-
bad8ea3:
DataGridtakes controlledcolumnSizing,columnOrderandcolumnVisibilityprops besidedefaultColumnSizing,defaultColumnOrderanddefaultColumnVisibility. Given one, the grid applies it as given, and a resize, a drop orshowColumns/hideColumnsasks for a change throughonColumnResize(whosesizingis the next state),onColumnOrderChangeoronColumnVisibilityChangeinstead of making it. -
bad8ea3:
DataGridtakes controlledcolumnSort,groupBy,groupExpansionandpaginationprops beside the existingdefault*ones. Given one, the grid shows exactly that value, and a header click, group toggle or pager button only asks for a change through the matchingon*Changecallback, taking effect once the prop follows:const [sort, setSort] = useState<ColumnSortState>([]); <DataGrid sortableColumns columnSort={sort} onColumnSortChange={(event) => setSort(event.sort)} />;Each slice is controlled or not on its own; passing both a controlled prop and its default logs a
console.erroronce and the controlled value wins. A controlledpaginationis not sent back to the first page when the filter, sort or grouping changes — reset it alongside the change if you want that. -
6af35c6: Cells and aggregates without a template now render through
formatCellValuefrom@gridkitjs/core, andDataGridtakes alocaleprop ("de-DE", or a list to fall back through).- A
Datecell renders as text instead of throwing, and a boolean cell readstrue/falseinstead of rendering nothing. - Formatting is opt-in: setting
locale, or a column'sformat, formats that column's dates and numbers throughIntlby itstype—currencywithformat.currency,percentreading0.25as 25%,dateandtimeshowing only that part. Without either, numbers, totals and group values read exactly as before. - Footer, group-summary and inline group aggregates then format like their
column's values (a
countreads as a plain number); a group header's value formats like its column's cells. - Announcements name a column by its new
headertext when it has one, so a column with a markupheaderTemplateis announced by name.
- A
-
78e10e5: Add
getPageRows()toDataGridApi: the current page ofgetDisplayRows(), exactly the rows the body renders — all of them whenpaginatedis off. -
bad8ea3:
DataGridApican now drive every slice of state, not only read it:setColumnSort,setGroupBy,setGroupExpansion,setPagination,setColumnSizing,setColumnOrder,setColumnVisibility,setRowSelection,setColumnSelectionandsetCellSelectioneach replace their slice and fire itson*Changecallback as a user's change would (nothing for an equal value; only a request for a controlled slice).getState()reads every slice at once andrestoreState(saved)puts a whole or partial state back with one re-render;serializeGridState, now re-exported from@gridkitjs/react, makes it safe to save as JSON.autoFitColumn(columnId)sizes a column to its content as double-clicking its resize handle does.setFilternow treats a filter equal in content to the current one as no change, rather than only the same entries. -
8d411eb:
DataGridtakesmessages, a partialGridMessagesthat replaces its own English strings key by key: the pager's buttons and status, the group-by bar, the "Loading more…" row, boolean cell text and a blank group's "(blank)", and every live-region announcement. Left out, every string reads exactly as before.GridMessagesis re-exported. -
bad8ea3:
@gridkitjs/coreexportsGridOptions<Row>: every grid setting that names no renderer type — data, row identity, what the user may do, starting state and change callbacks — in one interface, with theBorders,HoverableConfigandGroupByBarVisibilitytypes it uses.DataGridProps<Row>is now composed from it plusReactRenderSlots<Row>(columns,pager,infiniteScroll), the selection callbacks andref; every prop keeps its name and type.@gridkitjs/reactstill exportsBorders,HoverableConfigandGroupByBarVisibility, and now alsoGridOptionsandReactRenderSlots. -
da4fbda:
@gridkitjs/reactnow depends on@gridkitjs/dom, which holds the browser behavioursDataGridattaches. Nothing changes at a call site.The live region is now created by
@gridkitjs/dom'screateLiveAnnouncer, still as the last child of the grid's viewport element. One difference a screen-reader user can hear: an announcement identical to the one before it — the same column resized to the same width twice — is now read out again rather than silently dropped. -
487d8fa: Breaking: the grid component is renamed from
DataGridComponenttoDataGrid, matching itsDataGridPropsandDataGridApitypes. There is no deprecated alias — update the import and every JSX use:// before import { DataGridComponent } from "@gridkitjs/react"; <DataGridComponent columns={columns} dataSource={rows} />; // after import { DataGrid } from "@gridkitjs/react"; <DataGrid columns={columns} dataSource={rows} />;Development warnings logged by the grid are now prefixed
DataGrid:instead ofDataGridComponent:. -
8d411eb:
DataGridtakesonRowClickandonRowDoubleClick, called with the row, the column clicked and the modifiers held, andgetRowProps, which adds a class anddata-*attributes to each data row. Every data row now carriesdata-gridkit-row-id, its id asgetRowIdresolves it.selectable.toggleOnClickmakes a plain click toggle a row rather than select it alone.RowPointerEventandRowPropsare re-exported. -
bad8ea3:
DataGridApigainsselectRows(rowIds, intent?), which selects rows by id withinselectable.rows("replace"by default, or"toggle") and fires the row selection callbacks once, andgetSelectedRows(), which returns the selected rows themselves in selection order. Selection can also be held in your own state with the controlledrowSelection,columnSelectionandcellSelectionprops beside theirdefault*ones; a click then asks for a change through the selection callbacks instead of making it. -
bad8ea3: The filter can now change after mount.
DataGridApigainsgetFilter()andsetFilter(filter), which replaces the filter, sends the grid back to its first page and fires the newonFilterChangeprop once ({ filter }). AuseFilterState(gridRef)hook returns{ filter, setFilter }for a filter UI outside the grid, and a controlledfilterprop holds the filter in your own state alongsidedefaultFilter.
Patch Changes#
- 487d8fa: In a
virtualizedgrid, a key that moves focus to a row outside the mounted window (such as Ctrl+End) no longer gets stuck without scrolling when it is pressed while the grid is still updating from a scroll. - da4fbda: The body's delegated clicks, focus and keys find their cell or row through
@gridkitjs/dom'sbodyCellFrom,groupRowFromandbodyRowFrom. Nothing changes for a caller. - da4fbda: A right-button (or any non-primary) press on a column's resize handle no
longer starts a resize. Resizing otherwise works as before, now through
@gridkitjs/dom'sstartColumnResizeGesture. - da4fbda: A right-button (or any non-primary) press no longer starts a column-header or
group-by chip drag. Dragging otherwise works as before, now through
@gridkitjs/dom'sstartDragReorder. - da4fbda:
resizeMode: "fit"measures the grid through@gridkitjs/dom'sobserveElementWidth. Columns fit exactly as before. - da4fbda: Keyboard navigation runs on
@gridkitjs/dom'screateGridFocus. The keys, the tab stop,focusCellandgetFocusedCellbehave as before. - da4fbda:
infiniteScrollruns on@gridkitjs/dom'sattachInfiniteScroll. It loads exactly as before. - da4fbda:
virtualizedruns on@gridkitjs/dom'screateRowVirtualizer. Rows window, measure and scroll as before; scrolling that keeps the same rows mounted no longer re-renders the grid. - bad8ea3:
DataGridnow keeps its sort, filter, grouping, expansion, paging, column widths, order and visibility in@gridkitjs/core's grid controller rather than in React state, and draws the controller's view. Nothing changes for a grid using the existing props.DataGridApigetters now read the grid's current state at call time, so a read straight after an action such asgoToPagealready sees its result instead of the previous render's. - bad8ea3:
DataGridkeeps row, column and cell selection in its grid controller too, which fires the selection callbacks from one diff per change exactly as before. Nothing changes for a grid using the existing props. - 78e10e5: Resizing a column, or the grid's width changing, no longer re-runs filtering,
sorting, grouping and aggregation:
DataGridnow derives what it shows throughcreateGridViewResolverfrom@gridkitjs/core, whose row stages ignore column widths. Large datasets resize without stutter; nothing else changes. - 487d8fa: The build now starts with a
"use client"directive, so@gridkitjs/reactworks when imported from a Next.js App Router server component tree without a wrapper module of your own. - 487d8fa: Keyboard navigation in a
virtualizedgrid now moves the browser's focus to the cell it lands on once the grid has scrolled. Before, the focus could stay on the previous cell, or jump to a different row, while the highlighted cell moved on. - Updated dependencies [78e10e5]
- Updated dependencies [6af35c6]
- Updated dependencies [6af35c6]
- Updated dependencies [bad8ea3]
- Updated dependencies [bad8ea3]
- Updated dependencies [78e10e5]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [da4fbda]
- Updated dependencies [44759b4]
- Updated dependencies [bad8ea3]
- Updated dependencies [8d411eb]
- Updated dependencies [bad8ea3]
- Updated dependencies [78e10e5]
- Updated dependencies [44759b4]
- Updated dependencies [bad8ea3]
- Updated dependencies [8d411eb]
- @gridkitjs/core@0.11.0
- @gridkitjs/dom@0.1.0