Import

import-grid.ts
import { NuiGrid, NuiGridCell, type NuiGridColumn } from '@needless-ui/angular/grid';

NuiGrid

A data grid on a native table.

Selector
nui-grid
NuiGrid: Properties
NameTypeDefaultDescription
rowsTwo-wayreadonly T[]The data. Edits replace rows, so bind with [(rows)].
columnsInputNuiGridColumn<T>[]The columns, as NuiGridColumn objects.
rowIdInput(row: T) => unknownrow.id ?? rowA row’s key, for selection and tracking.
labelInputstringThe grid’s accessible name.
selectionInput'none' | 'single' | 'multiple''none'Whether rows can be selected, and how many.
selectedTwo-wayunknown[][]The keys of the selected rows.
sortTwo-wayNuiGridSort[][]The sort, as { column, direction } objects; the first sorts first.
filtersTwo-wayRecord<string, NuiGridFilter>{}A filter per column id: an operator and a value.
searchTwo-waystring''Words that must all appear in a row.
pageSizeTwo-waynumber0Rows per page, or 0 for one scrolling list.
pageTwo-waynumber0The page shown, from 0.
pageSizesInputnumber[][10, 25, 50, 100]The choices in the pager.
virtualInputboolean | 'auto''auto'Renders only the rows in view: always, never, or auto past 100 rows without pages.
heightInputstringA CSS length that bounds the grid; it scrolls inside.
columnStateTwo-wayNuiGridColumnState[][]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.
totalInputnumberThe number of rows on the server.
loadingInputbooleanfalseShows a progress bar, and placeholder rows while there are none.
localeInputstringLOCALE_IDFormats numbers and dates, and reads typed numbers.
labelsInputPartial<NuiGridLabels>Every text the grid shows or announces, to translate.
cornersInputNuiCornersThe shape of its corners: round, squircle, bevel, scoop, notch or square.
radiusInputNuiRadiusHow big its corners are: none, small, medium, large or full.
densityInputNuiDensityHow much room it takes: compact, regular or roomy.
rowActivateOutputTEmits a row opened with Enter or a double click.
cellEditOutputNuiGridEdit<T>Emits each committed edit.
queryChangeOutputNuiGridQueryEmits the sort, filters, search and page whenever they change.
exportCsvMethod(options?) => stringThe filtered, sorted rows of the visible columns, as CSV.
focusCellMethod(row: number, col: number) => voidFocuses a cell; row -1 is the header.
clearFiltersMethod() => voidClears 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.

NuiGridColumn: Properties
NameTypeDefaultDescription
idPropertystringUnique; the key in the sort, filters and column state.
headerPropertystringThe header text.
valuePropertykeyof 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.
formatPropertyIntl options | ((value, row) => string)Intl options for numbers and dates, or a function that makes the text.
optionsPropertyNuiOption<V>[]The choices of an enum column, as NuiOption objects.
width, minWidth, maxWidthPropertynumberIn pixels.
flexPropertynumberShares 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', booleanThe column’s first pin and visibility.
sortable, filterable, resizable, reorderable, hideablePropertybooleantrueEach can be turned off with false.
compareProperty(a: V, b: V) => numberA custom sort.
editable, validatePropertyboolean | ((row) => boolean), (value, row) => string | nullWhether cells can be edited, and a message when a value isn’t valid.
setProperty(row: T, value: V) => TMakes 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.

Selector
ng-template[nuiGridCell]
NuiGridCell: Properties
NameTypeDefaultDescription
nuiGridCellInputstringThe column’s id.

NuiGridHeader

Draws a column’s header.

Selector
ng-template[nuiGridHeader]
NuiGridHeader: Properties
NameTypeDefaultDescription
nuiGridHeaderInputstringThe column’s id.

NuiGridEmpty

What shows when there are no rows. The context says whether filters hid them.

Selector
ng-template[nuiGridEmpty]