Import
import { NuiGrid, type NuiGridColumn, type NuiGridHandle } from '@needless-ui/react/grid';NuiGrid
A data grid on a native table.
| Name | Type | Default | Description |
|---|---|---|---|
rowsProp | readonly T[] | The data. An edit replaces its row and calls onRowsChange; the next rows you pass replace the edits. | |
onRowsChangeCallback | (rows: readonly T[]) => void | Called with the rows after each committed edit. | |
columnsProp | NuiGridColumn<T>[] | The columns, as NuiGridColumn objects. | |
rowIdProp | (row: T) => unknown | row.id ?? row | A row’s key, for selection and tracking. |
labelProp | string | The grid’s accessible name. | |
selectionProp | 'none' | 'single' | 'multiple' | 'none' | Whether rows can be selected, and how many. |
selecteddefaultSelectedonSelectedChangeState | unknown[] | [] | The keys of the selected rows. |
sortdefaultSortonSortChangeState | NuiGridSort[] | [] | The sort, as { column, direction } objects; the first sorts first. |
filtersdefaultFiltersonFiltersChangeState | Record<string, NuiGridFilter> | {} | A filter per column id: an operator and a value. |
searchdefaultSearchonSearchChangeState | string | '' | Words that must all appear in a row. |
pageSizedefaultPageSizeonPageSizeChangeState | number | 0 | Rows per page, or 0 for one scrolling list. |
pagedefaultPageonPageChangeState | number | 0 | The page shown, from 0. |
pageSizesProp | number[] | [10, 25, 50, 100] | The choices in the pager. |
virtualProp | boolean | 'auto' | 'auto' | Renders only the rows in view: always, never, or auto past 100 rows without pages. |
heightProp | string | A CSS length that bounds the grid; it scrolls inside. | |
columnStatedefaultColumnStateonColumnStateChangeState | NuiGridColumnState[] | [] | Each column’s width, order, pin and visibility, to save and restore. |
modeProp | 'client' | 'server' | 'client' | server shows rows as they come and leaves sorting, filtering and paging to you. |
totalProp | number | The number of rows on the server. | |
loadingProp | boolean | false | Shows a progress bar, and placeholder rows while there are none. |
localeProp | string | 'en-US' | Formats numbers and dates, and reads typed numbers. |
labelsProp | Partial<NuiGridLabels> | Every text the grid shows or announces, to translate. | |
cornersProp | NuiCorners | The shape of its corners: round, squircle, bevel, scoop, notch or square. | |
radiusProp | NuiRadius | How big its corners are: none, small, medium, large or full. | |
densityProp | NuiDensity | How much room it takes: compact, regular or roomy. | |
groupByProp | string[] | [] | Columns to group rows by, outermost first. |
collapseddefaultCollapsedonCollapsedChangeState | string[] | [] | Keys of the groups closed; groups start open. |
getChildrenProp | (row: T) => T[] | undefined | A row’s children: the grid shows tree data. | |
expandeddefaultExpandedonExpandedChangeState | unknown[] | [] | Keys of the rows open in tree data; they start closed. |
detailsdefaultDetailsonDetailsChangeState | unknown[] | [] | Keys of the rows whose details are open. |
totals, flashProp | boolean | false | A row of aggregates over every filtered row; cells that flash when their text changes, in rows with a lasting rowId. |
layoutProp | 'table' | 'list' | 'auto' | 'table' | list shows rows as cards, and auto does on narrow screens. |
toolbarProp | boolean | 'auto' | 'auto' | A bar that sorts, filters and selects all rows: always, never, or auto with cards. |
renderEmptyRender prop | (filtered: boolean) => ReactNode | What shows when there are no rows; it’s told whether filters hid them. | |
renderDetailRender prop | (row: T) => ReactNode | A row’s details, shown under it when opened. The grid adds a column of toggles. | |
onRowActivateCallback | (row: T) => void | Called with a row opened with Enter or a double click. | |
onCellEditCallback | (edit: NuiGridEdit<T>) => void | Called with each committed edit. | |
onQueryChangeCallback | (query: NuiGridQuery) => void | Called with the sort, filters, search and page whenever they change, and once at the start. | |
refProp | Ref<NuiGridHandle> | What the grid’s ref reaches: exports, printing and focus. | |
exportXlsx, printMethod | (options?) => Blob, () => void | The filtered, sorted rows as a spreadsheet; prints every row. | |
exportCsvMethod | (options?) => string | The filtered, sorted rows of the visible columns, as CSV. | |
expandAllMethod | (open?: boolean) => void | Opens every group and every row with children, or closes them all. | |
focusCellMethod | (row: number, col: number) => void | Focuses a cell; row -1 is the header. | |
clearFiltersMethod | () => void | Clears every filter and the search. | |
fitMethod | (id: string) => void | Fits a column to the widest of its rendered cells. |
State works like React’s own inputs: pass a value and update it from its on…Change callback, or pass a default… value and let the component keep it.
Customization props you leave unset follow the nearest data-nui-* attribute. See the customization guide.
NuiGridColumn
One column. It takes every property of the Angular column (only id and header are required), and these two that draw it.
| Name | Type | Default | Description |
|---|---|---|---|
renderCellRender prop | ({ row, value, text, column }) => ReactNode | Draws the column’s cells yourself, from the row, its value and its text. | |
renderHeaderRender prop | (column) => ReactNode | Draws the column’s header yourself; header still names it. |