Import
import { NuiGrid, NuiGridCell, type NuiGridColumn } from '@needless-ui/angular/grid';NuiGrid
A data grid on a native table.
| Name | Type | Default | Description |
|---|---|---|---|
rowsTwo-way | readonly T[] | The data. Edits replace rows, so bind with [(rows)]. | |
columnsInput | NuiGridColumn<T>[] | The columns, as NuiGridColumn objects. | |
rowIdInput | (row: T) => unknown | row.id ?? row | A row’s key, for selection and tracking. |
labelInput | string | The grid’s accessible name. | |
selectionInput | 'none' | 'single' | 'multiple' | 'none' | Whether rows can be selected, and how many. |
selectedTwo-way | unknown[] | [] | The keys of the selected rows. |
sortTwo-way | NuiGridSort[] | [] | The sort, as { column, direction } objects; the first sorts first. |
filtersTwo-way | Record<string, NuiGridFilter> | {} | A filter per column id: an operator and a value. |
searchTwo-way | string | '' | Words that must all appear in a row. |
pageSizeTwo-way | number | 0 | Rows per page, or 0 for one scrolling list. |
pageTwo-way | number | 0 | The page shown, from 0. |
pageSizesInput | number[] | [10, 25, 50, 100] | The choices in the pager. |
virtualInput | boolean | 'auto' | 'auto' | Renders only the rows in view: always, never, or auto past 100 rows without pages. |
heightInput | string | A CSS length that bounds the grid; it scrolls inside. | |
columnStateTwo-way | NuiGridColumnState[] | [] | Each column’s width, order, pin and visibility, to save and restore. |
modeInput | 'client' | 'server' | 'client' | server shows rows as they come and leaves sorting, filtering and paging to you. |
totalInput | number | The number of rows on the server. | |
loadingInput | boolean | false | Shows a progress bar, and placeholder rows while there are none. |
localeInput | string | LOCALE_ID | Formats numbers and dates, and reads typed numbers. |
labelsInput | Partial<NuiGridLabels> | Every text the grid shows or announces, to translate. | |
cornersInput | NuiCorners | The shape of its corners: round, squircle, bevel, scoop, notch or square. | |
radiusInput | NuiRadius | How big its corners are: none, small, medium, large or full. | |
densityInput | NuiDensity | How much room it takes: compact, regular or roomy. | |
rowActivateOutput | T | Emits a row opened with Enter or a double click. | |
cellEditOutput | NuiGridEdit<T> | Emits each committed edit. | |
queryChangeOutput | NuiGridQuery | Emits the sort, filters, search and page whenever they change. | |
exportCsvMethod | (options?) => string | The filtered, sorted rows of the visible columns, as CSV. | |
focusCellMethod | (row: number, col: number) => void | Focuses a cell; row -1 is the header. | |
clearFiltersMethod | () => void | Clears every filter and the search. |
Customization inputs you leave unset follow the nearest data-nui-* attribute. See the customization guide.
NuiGridColumn
One column. Only id and header are required.
| Name | Type | Default | Description |
|---|---|---|---|
idProperty | string | Unique; the key in the sort, filters and column state. | |
headerProperty | string | The header text. | |
valueProperty | keyof T | ((row: T) => V) | A key of the row, or a function of the row. Defaults to row[id]. | |
typeProperty | 'text' | 'number' | 'date' | 'boolean' | 'enum' | 'text' | Picks the alignment, sort, filter and editor. |
formatProperty | Intl options | ((value, row) => string) | Intl options for numbers and dates, or a function that makes the text. | |
optionsProperty | NuiOption<V>[] | The choices of an enum column, as NuiOption objects. | |
width, minWidth, maxWidthProperty | number | In pixels. | |
flexProperty | number | Shares the room left over with the other flex columns. | |
alignProperty | 'start' | 'center' | 'end' | Defaults by type: numbers and dates at the end. | |
pinned, hiddenProperty | 'start' | 'end', boolean | The column’s first pin and visibility. | |
sortable, filterable, resizable, reorderable, hideableProperty | boolean | true | Each can be turned off with false. |
compareProperty | (a: V, b: V) => number | A custom sort. | |
editable, validateProperty | boolean | ((row) => boolean), (value, row) => string | null | Whether cells can be edited, and a message when a value isn’t valid. | |
setProperty | (row: T, value: V) => T | Makes the edited row. Defaults to a copy with the new value. |
NuiGridCell
Draws a column’s cells. The context holds the row, its value and its text.
| Name | Type | Default | Description |
|---|---|---|---|
nuiGridCellInput | string | The column’s id. |
NuiGridHeader
Draws a column’s header.
| Name | Type | Default | Description |
|---|---|---|---|
nuiGridHeaderInput | string | The column’s id. |
NuiGridEmpty
What shows when there are no rows. The context says whether filters hid them.