Skip to Content
NSUI

Data Grid

Sublist-style data grid with sorting, search, paging, totals and inline editing.

Use a data grid for sublist lines, search results and any list of records. It sorts, searches, selects, pages, totals and edits in place. Bind it to a native sublist with sublist="item".

Set columns and rows as properties from script. The attributes also accept JSON, which suits server-rendered HTML. Click a column header to sort: ascending, descending, then off.

Column types and alignment

type sets the format and the default alignment. number, currency, percent and actions align right; all other types align left. Set align to left, right or center to override it.

TypeOutput
textPlain text. An empty value shows a dash.
numberIntl.NumberFormat, up to 4 decimals.
currencyIntl.NumberFormat in the grid's currency (default USD).
percent0.25 shows as 25%.
dateYYYY-MM-DD or any date string, in medium date style.
badgeThe same label as nsui-badge. tones maps a value to success, warning, danger or info. A value with no tone is neutral.
linkA link. href is a row field name, or (row) => url. Only http, https, mailto and relative URLs become links; any other URL shows as plain text. target: '_blank' adds rel="noopener noreferrer".
monoMonospace text, for SKUs and IDs.
actionsIcon buttons from actions. See Row actions.

number, currency and percent cells and totals use tabular figures in one colour. A column with format or options shows its own text.

format: (value, row) => string replaces the text of any column. Search matches the formatted text. Set currency and locale on the grid to change the currency code and the number and date format.

HTML
<nsui-data-grid currency="EUR" locale="de-DE"></nsui-data-grid>

Search, column toggle and density

searchable adds a search box. It matches the text of the visible columns. column-toggle adds a Columns menu to show and hide columns. A column with hidden: true never shows and is not in the menu. density-toggle adds a button that switches density between default and compact.

Put your own actions in the toolbar slot. They sit on the right side of the toolbar.

HTML
<nsui-data-grid searchable>
  <nsui-button slot="toolbar" size="sm" variant="ghost">Remove</nsui-button>
</nsui-data-grid>

Filters

Set filter: true on a column to add a filter button for it to the toolbar. The button opens a panel with the column's distinct values and a count for each. Tick values to filter the rows. Values in one column combine with OR. Filters on different columns combine with AND. Each count shows how many rows would match that value, under the search and the other columns' filters.

  • The panel lists the column's labels: from options, then format, else the formatted value. It filters by the raw values.
  • A search box appears when a column has more than 8 values.
  • Clear empties one column's filter. Reset filters appears in the toolbar when any filter is active, and empties them all.
  • A change goes back to page 1. Selected rows that no longer pass the filters leave the selection, and selectionchange fires.
  • A column with hidden: true, or one hidden with the column menu, still filters.

filters holds the active filters: an object of column key to an array of values. Set it as a property, or as JSON in the attribute. The grid sets a new object each time the user changes a filter. It does not write the attribute back.

HTML
<nsui-data-grid filters='{"status":["Billed","Closed"],"location":["Main WH"]}'></nsui-data-grid>

The property also accepts a JSON string, as columns and rows do.

Keyboard: Enter or Space on a filter button opens its panel and moves focus to the first value (or the search box). Arrow keys move between values. Space ticks a value. Escape closes the panel and returns focus to the button.

Selection

selectable adds a checkbox column. The header checkbox selects all rows on the current page. Each change fires selectionchange with the selected keys and rows. Keys come from the row-key field (default id), or the row index when that field is missing.

When rows changes, the grid drops selected keys that no longer exist.

Paging

page-size turns on paging. 0 (the default) shows all rows. The pager has a rows-per-page select (10, 25, 50, 100) and page buttons. Search and sort apply to all rows before paging.

Totals

totals adds a footer row. Each column with a total shows a value: sum, avg, count, or a function (rows) => value. The first column shows "Total" when it has no total of its own. Totals use all rows that match the search, not only the current page.

Inline editing

Set editable: true on a column. Click a cell, or focus it and press Enter or F2, to open the editor. The editor is a number input for numeric types, a date input for date, a select when the column has options, and a text input otherwise.

KeyAction
EnterCommit and close.
EscapeClose without a change.
Tab / Shift+TabCommit and open the next or previous editable cell.
BlurCommit and close.

A changed value fires cellchange. If you do not cancel it, the grid writes the value to the row object and marks the cell with a corner flag. Call markClean() after a save to clear the flags. Call preventDefault() to reject the value.

The grid does not compute other columns. Update them in your cellchange handler, as above. If you mutate rows in place outside an edit, call refresh(). Assign a new array to rows to re-render and clear the dirty flags.

Pinned columns

pin: 'start' keeps a column on the left during horizontal scroll. pin: 'end' keeps it on the right. Pinned columns move to the start or end of the column order. The selection checkbox pins too when any column pins to the start.

Set --nsui-grid-max-height to scroll the body vertically. The header and the totals row stay in place.

Row status

A row with _status set to new, changed or deleted gets a green, amber or red tint. A deleted row also shows its text struck through. Set status-key to read the status from another field.

Expandable rows

expandable adds a chevron button to each row. It opens a detail row directly under that row. Put the detail content in light DOM with slot="detail-<row key>": your page styles, forms and NSUI components work inside it.

  • expanded lists the open row keys. Set it to open rows from code; the grid updates it when a user toggles a row.
  • detail-mode="single" (the default) closes the open row when another opens. multi keeps several open.
  • The detail stays in view when the columns scroll sideways.
  • Keyboard: Enter or Space toggles the focused chevron; Right Arrow opens and Left Arrow closes.
Committed 12 · Fulfilled 12 · Billed 12
Committed 40 · Fulfilled 0 · Billed 0 · Ship date Dec 9, 2026
Backordered 1 · Next receipt Dec 14, 2026

Detail content is your own markup, never an HTML string from data, so it cannot inject script.

Cell marks, tones and weight

Three column fields change how a cell looks. None of them takes HTML.

  • mark: (value, row) => name | { name, label, tone } | null puts a 16px mark before the text. tone replaces the mark's default colour. Names: locked (padlock), blocked (slash), edited (ring), new (plus), warning (triangle). The label is the mark's accessible name and tooltip; each name has a default. Any other name shows nothing.
  • tones colours the cell text on any column that is not a badge, with the same map or function as a badge: success, warning, danger or info.
  • weight: regular (default), medium or semibold, or (value, row) => weight for one cell at a time.

Row actions

A column with type: 'actions' shows icon buttons in each row. actions lists them: { name, icon, label, disabled?, hidden? }. icon is trash or restore. label is the button's accessible name and tooltip. disabled and hidden are (row) => boolean: a disabled button shows dimmed, a hidden one is left out for that row. A click fires rowaction with { name, key, row, index }; rowclick does not fire. The column does not sort and search skips it. Pin it with pin: 'end' to keep it in view.

Theming

Set these tokens on the grid or on any ancestor. Each one defaults to the look above.

TokenSetsDefault
--nsui-grid-header-bgHeader row background--nsui-bg
--nsui-grid-header-fgHeader text colour--nsui-fg
--nsui-grid-header-weightHeader font weight500
--nsui-grid-divider1px rule between columnsnone
--nsui-grid-stripeBackground of every second line (detail rows do not count)none
--nsui-grid-edited-bgFill of an edited cell, under the corner marknone
--nsui-grid-max-heightHeight after which the body scrollsnone

For anything else in the header, style ::part(header).

Loading

loading replaces the body with skeleton rows while you fetch data. The totals row hides while it loads.

When no rows match, the body shows empty-text (default "No results.").

Events

All events bubble and cross the shadow boundary.

EventDetailCancel effect
sort{ key, dir }, dir is 'asc', 'desc' or nullKeeps the current sort.
selectionchange{ keys, rows }None.
cellchange{ row, key, value, oldValue, index }Keeps the old value.
filterchange{ key, values, filters }. key is null for Reset filters.Keeps the current filters.
rowclick{ row, index }None.
rowtoggle{ key, row, open }Keeps the row open or closed.
rowaction{ name, key, row, index }None.

index is the position in rows, not in the sorted or paged view. rowclick does not fire for clicks on checkboxes, links, buttons or editable cells.

In NetSuite

Add sublist="item" to bind the grid to a native sublist on a record page. Each column key is a sublist field ID. Set field on a column when the key differs from the field ID, and text: true to show the field's display text instead of its value.

HTML
<nsui-data-grid sublist="item" totals columns='[
  {"key":"item","label":"Item","text":true},
  {"key":"quantity","label":"Qty","type":"number","editable":true,"total":"sum"},
  {"key":"rate","label":"Rate","type":"currency","editable":true},
  {"key":"amount","label":"Amount","type":"currency","total":"sum"}
]'></nsui-data-grid>
  • The native record stays the source of truth. The grid reads every line with getLineCount and getSublistValue (or getSublistText).
  • An edit cancels the grid's own write. The binding then calls selectLine, setCurrentSublistValue and commitLine, so NetSuite runs fieldChanged, sourcing and validateLine as usual.
  • If commitLine throws, or the committed value differs from the new value, the binding calls cancelLine. It fires a cancelable nserror event and, if not cancelled, shows a "Line not saved" toast. The grid then re-reads the record, so the cell reverts.
  • The grid polls the sublist about every 1.2 seconds. It skips a poll while a cell editor is open. Call NSUI.sync() from a client script for an instant refresh.
  • In view mode, all columns become read-only.

API

Attributes

Prop

Type

Properties

Prop

Type

Events

Prop

Type

Slots

Prop

Type

CSS parts

Prop

Type

CSS custom properties

Prop

Type

NSUI is a community project. It is not an official Oracle NetSuite product. NetSuite is a trademark of Oracle.

On this page