API reference
createGrid(element, options) returns this API. Calls after destroy() do nothing.
createGrid(element, options) returns this API. Calls after destroy() do nothing.
| Method | Returns | Description |
|---|---|---|
setData(rows, { scrollToTop? }) | void | Replace all rows. The scroll position stays unless scrollToTop is set. |
getData() | Row[] | Current rows (unfiltered, unsorted). |
getRowById(id) / getRowIndex(rowOrId) | Row | undefined / number | A row by its getRowId id (filtered-out rows too); where a row is shown, -1 when it is not. |
getDisplayedRows() / getDisplayedRowAt(index) | Row[] / Row | undefined | Data rows in the order shown (group rows left out); the data row at a display index. |
forEachRow(fn, scope?) | void | fn(row, index) for every row of the data, or every shown row with 'displayed'. |
getCellValue(rowOrId, colId) / setCellValue(rowOrId, colId, value) | unknown / boolean | Read a cell as the grid does; write one like an edit (undo, change mark, cellValueChanged; rules not checked). |
refreshCells({ rows?, colIds?, flash? }) | void | Repaint rows whose objects you changed yourself; flash marks the cells. Sorting and filters are not run again. |
getFocusedCell() / setFocusedCell(rowIndex, colId) / ensureCellVisible(rowIndex | null, colId?) | { rowIndex, colId, row } | null / void / void | Read the focused cell; focus a cell, scroll to it and give the grid the keyboard; scroll a cell (or, with null, a column) into view. |
setColumns(defs) | void | Replace column definitions. Widths, order, visibility and pinning the user changed stay unless the new definitions change them; the same definitions again do nothing. |
getColumnState() / applyColumnState(state) | ColumnState[] | Save and restore order, width, visibility and pinning. |
resetColumnState() | void | Back to the column definitions (drops what the user changed). |
setColumnVisible(colId, visible) | void | Show or hide a column. |
autoSizeColumns(colIds?) | void | Fit widths to header and visible cells. |
openColumnChooser() / closeColumnChooser() | void | Floating column chooser. |
toggleSideBar(open?)Paid | void | Open or close the docked Columns panel. |
setSort(items) / getSort() | SortItem[] | e.g. [{ colId: 'total', dir: 'desc' }]. |
setCellNote / getCellNote / getCellNotes / editCellNote | void / string | null / CellNote[] / void | Cell notes by row id and column (undoable). |
addCalculatedColumn / removeCalculatedColumn / getCalculatedColumns / openCalculatedColumnDialog | string | null / void / CalculatedColumn[] / void | Formula columns made at run time. |
setColumnValuesAs(colId, mode) / setAllDetailsExpanded(open) | void | Show a column as a share or running total; open or close every detail row. |
refreshRows({ keepRows }) / getXlsxAsync(options) | void / Promise<Uint8Array> | Reload server rows keeping the loaded ones on screen; Excel bytes with pictures. |
resetColumnState() / clearSavedState() | void | Back to the column definitions (remembered with stateKey); forget the saved state. |
validate(options?) / validateCell(row, colId) | InvalidCell[] / string | null | Check rules for all, some (rows, colIds, changedOnly) or one cell. |
setFilter(colId, model | null) / getFilterModel() | FilterModel | Set or clear one column filter. Text ops: contains, notContains, equals, notEquals, startsWith, endsWith, in, like, regex, blank, notBlank. Date ops add notEquals and relative ones: today, yesterday, thisWeek, lastWeek, thisMonth, lastMonth, thisQuarter, thisYear, lastYear, lastDays / nextDays (with days). |
setQuickFilter(text) | void | Search all visible columns: every word must match; "a phrase" as written, -word excludes, Korean initials work. |
getSelectedRows() / selectAll() / deselectAll() | Row[] | Selection helpers. selectAll selects the filtered rows; with a datasource, the loaded rows. |
setSummary(options | null) / getSummaryValues()Paid | object[] | Change summary rows; read raw totals. |
getRange() / setRange(range | null)Paid | GridRange | Read or set the active cell range. |
getRanges() / setRanges(ranges)Paid | GridRange[] | All ranges, including those added with Ctrl+click or Ctrl+drag; the last one is active. |
copySelection({ headers? })Paid · multi-cell ranges | string | Copy the range as Excel TSV and return it. With a datasource, only loaded rows are copied (a console warning counts the rest). |
pasteText(text)Paid · multi-cell paste | { changed, skipped } | Paste TSV/Excel text at the range or focused cell. |
startEdit(rowIndex, colId) / stopEdit(cancel?) | boolean / void | Open or close the editor. |
addRows(rows, index?) / removeRows(rows | fn) / removeSelectedRows() | Row[] | Insert or remove rows (tracked, undoable). |
getModifiedRows() / getChanges() / hasChanges() | object | Created/updated/deleted rows and column-level diffs. |
commitChanges() / revertChanges() | void | Accept changes as the new baseline, or undo all of them. |
undo() / redo() / canUndo() / canRedo() | void / boolean | Undo history for edits, pastes and row changes. |
fillRange(target)Paid | void | Fill from the selection into a larger range (series aware). |
find(text) / findNext() / findPrevious() / clearFind()Paid | number / void | Highlight and step through matching cells. |
setPinnedRows({ top?, bottom? }) | void | Change pinned rows. |
setSortWithinMerges(on) / getSortWithinMerges()Paid | void / boolean | Turn sortWithinMerges on or off; the rows are sorted again at once. |
setMergeSelection(level) / getMergeSelection()Paid | void / 'rows' | number | Put the checkboxes on every row ('rows') or on the blocks of a merge level; the selection is kept. |
getSelectedGroupsAllRows()Paid | { level, values, rows }[] | Like getSelectedGroups(), but each block lists all its rows that pass the filters, selected or not. |
getSelectedGroups()Paid | { level, values, rows }[] | Selected rows by merged block: the merge values of each block and its selected rows ([] with one checkbox per row). |
setGroupBy(colIds) / getGroupBy()Paid | void / string[] | Change or read the grouping. |
expandAll() / collapseAll() / setGroupExpanded(key, open) | void | Open or close groups and tree rows. Group keys look like 'country:KR|city:Seoul'; tree keys are row ids. |
setDetailExpanded(row, open) / isDetailExpanded(row) | void / boolean | Open, close or check a detail panel. |
dropRow(row, target, position?) | boolean | Move a row 'before', 'after' or (tree data) 'inside' another row; null target = to the end. False when refused. |
moveRow(row, toIndex) | boolean | Move a row in the source data (undoable). False while sorting, filtering or grouping. |
setPage(n) / getPage() / getPageCount() | void / number | Move between pages (0-based). |
setPageSize(n) / getPageSize() | void / number | Change rows per page. |
refreshRows() | void | Server data: drop cached rows and load again. |
exportXlsx(filename?, options?) / getXlsx(options?)Paid | void / Uint8Array | Excel file of the rows. Options: columns, rows (filtered | all | selected), headers, sheetName, styles (column align and cellClass colors, default true). |
exportCsv(filename?, options?) / getCsv(options?) | void / string | CSV with a BOM so Excel reads Korean; same options plus separator. |
exportJson(filename?, options?) / getJson(options?) | void / string | The rows as an array of objects keyed by column id (keys: 'header' for headers); formatted: true saves the text as shown. |
exportPdf(filename?, options?) / getPdf(options?)Paid | void / Uint8Array | null | The print layout as a PDF made in the browser (any script), with repeatHeader, repeatRows and repeatTitle. |
importFile(file, { mode?, sheet? }) | Promise<{ rows, skipped }> | Read .xlsx or CSV; headers are matched to columns; append (default) or replace. |
toggleSideBar(open?, panel?)Paid | void | Open or close the side bar, optionally on 'columns' or 'filters'. |
setRollup({ by } | true | false) / getRollup()Paid | void / boolean | { by } | Merge rows by columns, change the by columns, or show the original rows again (false). |
setColumnAggFunc(colId, aggFunc | null) | void | A column's aggregate for group rows and rollup: 'sum', 'avg', 'min', 'max', 'count' or a function; null removes it. |
setPivot(config | null) / getPivot()Paid | void / PivotConfig | null | Turn the pivot on, change it, or return to the normal view. |
createChart({ type?, range?, container?, title? })Paid | { el, setType, update, destroy } | SVG chart of the range or the whole view: 'bar', 'stackedBar', 'line', 'area', 'pie'. |
version | string | Exported constant with the package version, e.g. import { version }. |
getDisplayedRowCount() | number | Rows after filtering. |
scrollToRow(index) | void | Scroll a displayed row into view. |
getScrollPosition() / setScrollPosition({ top?, left? }) | { top, left } | Read or set the scroll offsets of the rows area in px. |
syncScroll(otherGrid, axis?) | () => void | Scroll two grids together ('both', 'vertical' or 'horizontal'); returns a function that unlinks them. |
validate() | { row, rowIndex, colId, message }[] | Check every editable cell against required, unique and validate; empty when all rows are valid. |
getState() / setState(state, { parts? }) | SavedGridState | The whole view as plain JSON — columns, sort, filters, advanced filter, grouping, open groups, column groups, page, selection — to save per user and restore. |
applyTransaction({ add?, addIndex?, update?, remove? }) / applyTransactionAsync(tx) | TransactionResult / void | Change rows by id (live data). Not undoable, not tracked as edits; changed cells flash. The async version merges calls into one update about every 50 ms. Passing a row object of the grid after changing it in place repaints the whole row (it does not flash). |
flushAsyncTransactions() | void | Apply the queued applyTransactionAsync updates now. A transaction may also have upsert: rows updated by id or added. |
setConditionalFormats(list) / getConditionalFormats() / openConditionalFormats(colId)Paid | void / ConditionalFormat[] / void | Replace or read the conditional formats; open the dialog for a column. |
setAdvancedFilter(filter | null) / getAdvancedFilter() / openFilterBuilder()Paid | void / AdvancedFilter | null / void | Conditions across columns with nested and / or: { operator: 'or', conditions: [{ colId, model }, { operator: 'and', conditions: [...] }] }. |
cutSelection()Paid · multi-cell ranges | string | Copy the range, then clear its editable cells (one undo step). Also Ctrl+X. |
stopRowEdit(cancel?) | void | editType 'row': finish the row being edited. |
setColumnGroupOpened(groupId, open) / isColumnGroupOpened(groupId) | void / boolean | Open or close a collapsible column group. |
print(options?) / getPrintHtml(options?) | void / string | Print the rows as a table: group and summary rows, page numbers. Options: the export options plus title, subtitle, footer, paper, orientation, fitToWidth, groups, summary, striped, pageNumbers, printedAt, rowNumbers. |
getXlsxSheet(options?)Paid | XlsxSheet | One worksheet of the rows, for buildWorkbook / exportWorkbook. |
setDensity(density) / getDensity() | void / string | 'compact', 'normal' or 'comfortable'. |
showOverlay(kind | null) | void | Show the 'loading' or 'noRows' overlay yourself; null goes back to automatic. |
restDatasource(url, options?) · loadData(grid, url, options?) · saveChanges(grid, url, options?) · csrfHeaders() | module functions | Server helpers (Spring Boot, eGovFrame…): a datasource over POST JSON, "search, edit, save" screens, and the Spring Security CSRF header. See Server integration. |
buildWorkbook(sheets) / exportWorkbook(filename, sheets)Paid | module functions | One .xlsx with a sheet per grid: [{ grid, sheetName, options }]. |
setLicenseKey(key) · verifyLicense(key, host) | module functions | The license key for every grid on the page; verifyLicense checks a key for a host (Promise of { ok, info } or { ok: false, reason }). |
readXlsx(bytes) · writeXlsx(sheets) · parseCsv(text, separator?) | module functions | Read an .xlsx file into sheets of cell values, write one, or split CSV / TSV text into rows (the separator is detected when left out). importFile() uses them. |
connectLive(grid, options) · messageToTransaction(message) | module functions | Stream WebSocket, server-sent events or polling into a grid; messageToTransaction is the default message reader (JSON text, an array of rows, { add, update, remove } or { rows }). |
evaluateFormula(formula, row) · registerFormulaFunction(name, fn) · formulaFunctions | module functions | Evaluate a formula such as '=qty * price' against a row, add your own function, or list the built-in ones. |
registerLocale(pack) · resolveLocale(codeOrPack?) | module functions | Add a language pack, or get the pack a code (or the browser languages) resolves to. |
renderChart(element, spec) | module function | Draw a bar, line, area, pie or scatter chart from your own numbers, without a grid. |
changeTracker(initial) | module function | For framework wrappers: a function that says whether a new option value differs in content from the last one (an inline literal re-created on every render does not). |
setTheme(name) | void | Switch theme. |
setFont({ size?, family? }) | void | Change font; family null restores the theme font. |
setCellPadding(px | null) / getCellPadding() | void / number | Cell padding for every cell and header at once; null goes back to the theme / density value. getCellPadding returns the px in use. |
setLocale(codeOrPack) | void | Switch UI language. |
on(event, handler) | () => void | Subscribe; returns an unsubscribe function. |
destroy() | void | Remove the grid and its listeners. |