Data Grid Options

Options

Full reference of CoreUI Data Grid constructor options — columns, data, features and behavior.

Pass options to the constructor: new DataGrid(element, options). Update them later with grid.update(options).

OptionTypeDefaultDescription
cellNavigationbooleanfalseAPG grid keyboard navigation — role="grid", a roving-tabindex active cell and arrow-key movement. See Keyboard navigation.
columnsDataGridColumn[][]Column definitions — see Columns.
columnFiltersbooleanfalseRenders a filter row in the header with an input per filterable column. See Filtering.
columnMenuboolean | ((ctx) => DataGridMenuAction[])falseAdds a per-column header menu. true builds it from the enabled features (sort/pin/move/hide); a builder ({ column, defaultActions }) => actions returns the final item list. See Column menu.
columnOrderboolean | string[]falseDrag-and-drop column reordering; an array sets the initial order. Reordering never crosses a pinning boundary. See Column ordering.
columnPinningboolean | { left?: string[], right?: string[] }falseFreezes columns (by key) to the left/right edge with sticky positioning. true enables the feature with no initial pins. See Column pinning.
columnVisibilityboolean | Record<string, boolean>falseEnables hiding/showing columns via column.toggleVisibility(); an object sets the initial visibility.
columnSizingboolean | { mode?: 'onChange' | 'onEnd' }falseEnables column resize handles. mode controls whether widths update while dragging ('onChange', the default) or on release ('onEnd'). See Column sizing.
dataProvider(request) => Promise<{ items, totalRows }>nullServer-side mode: the grid requests data on every sorting/filter/page change. The request carries { sorting, columnFilters, globalFilter, pagination }. Implies pagination. See Server-side data.
editingbooleanfalseInline cell editing on Enter/F2/double-click for columns opting in via editable/editor; implies cellNavigation. See Inline editing.
emptystring | () => Node | string'No items found'Content shown when no rows match.
globalFilterbooleanfalseRenders a search input above the grid that filters across all columns. Shorthand for toolbar: { search: true }.
historybooleanfalseUndo/redo stack over edit commits — toolbar buttons and Ctrl+Z / Ctrl+Shift+Z / Ctrl+Y. See Undo & redo.
itemKey(item, index) => stringnullStable row id — required for selection to survive sorting and filtering.
itemsobject[][]Row data.
labelsPartial<DataGridLabels>{}UI strings (i18n), merged over the defaults. Supports {token} interpolation. See Localization.
overscannumber10Extra rows rendered above and below the visible window.
paginationboolean | { pageSize?, pageSizeOptions?, position?, info? }falsePagination mode — mutually exclusive with virtualization. See Pagination.
rowHeightnumber44Estimated row height in px used by the virtualizer.
rowSelectionboolean | { selectAll? }falseCheckbox selection with select-all and shift+click ranges. See Row selection.
sanitizebooleantrueSanitize icon markup against the SVG allow list before inserting it.
sanitizeFn(html) => string | nullnullCustom sanitizer used in place of the built-in one.
slots{ toolbar?, pagination?, empty? }{}Replaces built-in chrome. Each slot is a factory ({ table, labels }) => ({ element, update?, dispose? }). See Slots.
stateKeystring | nullnullAutosaves the grid state to localStorage under this key (debounced) and restores it on init. See Save & restore state.
sortingboolean | { multiple?, resetable? }trueColumn sorting; shift+click adds columns to the sort. See Sorting.
toolbarboolean | { columns?, export?, history?, search? }falseBuilt-in toolbar above the grid. true enables every action whose feature is on; a granular object picks each. columns needs columnVisibility; export accepts a CsvDownloadOptions object; history needs the history option; search is the same input as globalFilter. See Toolbar.
virtualizationbooleantrueWindowed rendering for large datasets. See Virtualization.

Every menu and header icon is overridable with its own string option (SVG markup): columnMenuIcon, sortAscendingIcon, sortDescendingIcon, sortNeutralIcon, pinLeftIcon, pinRightIcon, unpinIcon, moveLeftIcon, moveRightIcon, hideColumnIcon, toolbarColumnsIcon, toolbarExportIcon, toolbarUndoIcon and toolbarRedoIcon. They default to the CoreUI icon set and are sanitized like any other icon.