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). |
setColumns(defs) | void | Replace column definitions. |
getColumnState() / applyColumnState(state) | ColumnState[] | Save and restore order, width, visibility and pinning. |
resetColumnState() | void | Back to the column definitions. |
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?) | void | Open or close the docked Columns panel. |
setSort(items) / getSort() | SortItem[] | e.g. [{ colId: 'total', dir: 'desc' }]. |
setFilter(colId, model | null) / getFilterModel() | FilterModel | Set or clear one column filter. |
setQuickFilter(text) | void | Search all visible columns. |
getSelectedRows() / selectAll() / deselectAll() | Row[] | Selection helpers. selectAll selects the filtered rows. |
setSummary(options | null) / getSummaryValues() | object[] | Change summary rows; read raw totals. |
getRange() / setRange(range | null) | GridRange | Read or set the active cell range. |
getRanges() / setRanges(ranges) | GridRange[] | All ranges, including those added with Ctrl+click or Ctrl+drag; the last one is active. |
copySelection({ headers? }) | string | Copy the range as Excel TSV and return it. |
pasteText(text) | { 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) | void | Fill from the selection into a larger range (series aware). |
find(text) / findNext() / findPrevious() / clearFind() | number / void | Highlight and step through matching cells. |
setPinnedRows({ top?, bottom? }) | void | Change pinned rows. |
setGroupBy(colIds) / getGroupBy() | 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?) | 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?) | 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?) | void | Open or close the side bar, optionally on 'columns' or 'filters'. |
setPivot(config | null) / getPivot() | void / PivotConfig | null | Turn the pivot on, change it, or return to the normal view. |
createChart({ type?, range?, container?, title? }) | { 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. |
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) | void / ConditionalFormat[] / void | Replace or read the conditional formats; open the dialog for a column. |
askAssistant(prompt) / openAssistant() | Promise<AssistantResult> / void | Ask the AI assistant from code (the result has message, applied, skipped and undo()), or open its chat panel. |
setAdvancedFilter(filter | null) / getAdvancedFilter() / openFilterBuilder() | void / AdvancedFilter | null / void | Conditions across columns with nested and / or: { operator: 'or', conditions: [{ colId, model }, { operator: 'and', conditions: [...] }] }. |
cutSelection() | 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?) | 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) | module functions | One .xlsx with a sheet per grid: [{ grid, sheetName, options }]. |
setTheme(name) | void | Switch theme. |
setFont({ size?, family? }) | void | Change font; family null restores the theme font. |
setLocale(codeOrPack) | void | Switch UI language. |
on(event, handler) | () => void | Subscribe; returns an unsubscribe function. |
destroy() | void | Remove the grid and its listeners. |