Data Grid Methods

Methods

CoreUI Data Grid instance methods — selection, CSV export, updating options, disposal and the headless table getter.

Call these on the DataGrid instance returned by the constructor.

MethodDescription
getSelectedItems()Returns the selected item objects.
getRowElement(id)Returns the rendered row with the given id (itemKey), or null. See Rows and cells in the DOM.
getCellElement(id, columnId)Returns the rendered data cell of that row and column, or null.
getCsv(options?)Returns the rows as an RFC-4180 CSV string. Options: scope, delimiter, bom, sanitize. See CSV export.
downloadCsv(options?)Downloads the CSV as a file. Same options plus filename.
print()Prints every sorted and filtered row through a plain generated table, past virtualization and pagination. See Print.
getState()Serializable snapshot of every user-adjustable state slice. See Save & restore state.
restoreState(state)Applies a (partial) snapshot back onto the grid.
undo()Reverts the most recent edit commit by re-emitting editCommit with the values swapped. Requires history: true.
redo()Re-applies the most recently undone edit commit.
isDirty()Returns whether any cell differs from its value before its first commit. Requires editTracking: true; see Edit tracking.
getEditedCells()Returns the edited cells as { rowId, columnId, item, value, originalValue }[].
isValid()Returns whether no row has an error from validate. See Validating the data.
getInvalidCells(level?)Returns { rowId, columnId, item, message, level }[] for every row, optionally only 'error' or 'warning'.
clearEdited()Forgets the original values, so no cell counts as edited. Call it after saving.
setItems(items)Replaces the data in place, preserving sorting, filters, selection and scroll. Pair with itemKey so selection follows items rather than row indexes. Ignored in server-side mode, where the dataProvider owns the data.
update(options)Merges options and performs a full rebuild — sorting, filters, selection and scroll are reset. Use setItems() to swap data while keeping user state.
dispose()Destroys the instance and removes the rendered UI.
table (getter)The underlying headless table instance — the headless escape hatch for building custom UI.