FreeGridv1.15.1한국어

API reference

createGrid(element, options) returns this API. Calls after destroy() do nothing.

createGrid(element, options) returns this API. Calls after destroy() do nothing.

MethodReturnsDescription
setData(rows, { scrollToTop? })voidReplace all rows. The scroll position stays unless scrollToTop is set.
getData()Row[]Current rows (unfiltered, unsorted).
getRowById(id) / getRowIndex(rowOrId)Row | undefined / numberA row by its getRowId id (filtered-out rows too); where a row is shown, -1 when it is not.
getDisplayedRows() / getDisplayedRowAt(index)Row[] / Row | undefinedData rows in the order shown (group rows left out); the data row at a display index.
forEachRow(fn, scope?)voidfn(row, index) for every row of the data, or every shown row with 'displayed'.
getCellValue(rowOrId, colId) / setCellValue(rowOrId, colId, value)unknown / booleanRead a cell as the grid does; write one like an edit (undo, change mark, cellValueChanged; rules not checked).
refreshCells({ rows?, colIds?, flash? })voidRepaint 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 / voidRead 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)voidReplace 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()voidBack to the column definitions (drops what the user changed).
setColumnVisible(colId, visible)voidShow or hide a column.
autoSizeColumns(colIds?)voidFit widths to header and visible cells.
openColumnChooser() / closeColumnChooser()voidFloating column chooser.
toggleSideBar(open?)voidOpen or close the docked Columns panel.
setSort(items) / getSort()SortItem[]e.g. [{ colId: 'total', dir: 'desc' }].
setCellNote / getCellNote / getCellNotes / editCellNotevoid / string | null / CellNote[] / voidCell notes by row id and column (undoable).
addCalculatedColumn / removeCalculatedColumn / getCalculatedColumns / openCalculatedColumnDialogstring | null / void / CalculatedColumn[] / voidFormula columns made at run time.
setColumnValuesAs(colId, mode) / setAllDetailsExpanded(open)voidShow 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()voidBack to the column definitions (remembered with stateKey); forget the saved state.
validate(options?) / validateCell(row, colId)InvalidCell[] / string | nullCheck rules for all, some (rows, colIds, changedOnly) or one cell.
setFilter(colId, model | null) / getFilterModel()FilterModelSet 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)voidSearch 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()object[]Change summary rows; read raw totals.
getRange() / setRange(range | null)GridRangeRead 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? })stringCopy the range as Excel TSV and return it. With a datasource, only loaded rows are copied (a console warning counts the rest).
pasteText(text){ changed, skipped }Paste TSV/Excel text at the range or focused cell.
startEdit(rowIndex, colId) / stopEdit(cancel?)boolean / voidOpen or close the editor.
addRows(rows, index?) / removeRows(rows | fn) / removeSelectedRows()Row[]Insert or remove rows (tracked, undoable).
getModifiedRows() / getChanges() / hasChanges()objectCreated/updated/deleted rows and column-level diffs.
commitChanges() / revertChanges()voidAccept changes as the new baseline, or undo all of them.
undo() / redo() / canUndo() / canRedo()void / booleanUndo history for edits, pastes and row changes.
fillRange(target)voidFill from the selection into a larger range (series aware).
find(text) / findNext() / findPrevious() / clearFind()number / voidHighlight and step through matching cells.
setPinnedRows({ top?, bottom? })voidChange pinned rows.
setSortWithinMerges(on) / getSortWithinMerges()void / booleanTurn sortWithinMerges on or off; the rows are sorted again at once.
setMergeSelection(level) / getMergeSelection()void / 'rows' | numberPut the checkboxes on every row ('rows') or on the blocks of a merge level; the selection is kept.
getSelectedGroupsAllRows(){ level, values, rows }[]Like getSelectedGroups(), but each block lists all its rows that pass the filters, selected or not.
getSelectedGroups(){ 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()void / string[]Change or read the grouping.
expandAll() / collapseAll() / setGroupExpanded(key, open)voidOpen 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 / booleanOpen, close or check a detail panel.
dropRow(row, target, position?)booleanMove a row 'before', 'after' or (tree data) 'inside' another row; null target = to the end. False when refused.
moveRow(row, toIndex)booleanMove a row in the source data (undoable). False while sorting, filtering or grouping.
setPage(n) / getPage() / getPageCount()void / numberMove between pages (0-based).
setPageSize(n) / getPageSize()void / numberChange rows per page.
refreshRows()voidServer data: drop cached rows and load again.
exportXlsx(filename?, options?) / getXlsx(options?)void / Uint8ArrayExcel 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 / stringCSV with a BOM so Excel reads Korean; same options plus separator.
exportJson(filename?, options?) / getJson(options?)void / stringThe 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 | nullThe 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?)voidOpen or close the side bar, optionally on 'columns' or 'filters'.
setRollup({ by } | true | false) / getRollup()void / boolean | { by }Merge rows by columns, change the by columns, or show the original rows again (false).
setColumnAggFunc(colId, aggFunc | null)voidA column's aggregate for group rows and rollup: 'sum', 'avg', 'min', 'max', 'count' or a function; null removes it.
setPivot(config | null) / getPivot()void / PivotConfig | nullTurn 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'.
versionstringExported constant with the package version, e.g. import { version }.
getDisplayedRowCount()numberRows after filtering.
scrollToRow(index)voidScroll 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?)() => voidScroll 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? })SavedGridStateThe 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 / voidChange 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()voidApply the queued applyTransactionAsync updates now. A transaction may also have upsert: rows updated by id or added.
setConditionalFormats(list) / getConditionalFormats() / openConditionalFormats(colId)void / ConditionalFormat[] / voidReplace or read the conditional formats; open the dialog for a column.
setAdvancedFilter(filter | null) / getAdvancedFilter() / openFilterBuilder()void / AdvancedFilter | null / voidConditions across columns with nested and / or: { operator: 'or', conditions: [{ colId, model }, { operator: 'and', conditions: [...] }] }.
cutSelection()stringCopy the range, then clear its editable cells (one undo step). Also Ctrl+X.
stopRowEdit(cancel?)voideditType 'row': finish the row being edited.
setColumnGroupOpened(groupId, open) / isColumnGroupOpened(groupId)void / booleanOpen or close a collapsible column group.
print(options?) / getPrintHtml(options?)void / stringPrint 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?)XlsxSheetOne worksheet of the rows, for buildWorkbook / exportWorkbook.
setDensity(density) / getDensity()void / string'compact', 'normal' or 'comfortable'.
showOverlay(kind | null)voidShow the 'loading' or 'noRows' overlay yourself; null goes back to automatic.
restDatasource(url, options?) · loadData(grid, url, options?) · saveChanges(grid, url, options?) · csrfHeaders()module functionsServer 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 functionsOne .xlsx with a sheet per grid: [{ grid, sheetName, options }].
setLicenseKey(key) · verifyLicense(key, host)module functionsThe 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 functionsRead 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 functionsStream 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) · formulaFunctionsmodule functionsEvaluate a formula such as '=qty * price' against a row, add your own function, or list the built-in ones.
registerLocale(pack) · resolveLocale(codeOrPack?)module functionsAdd a language pack, or get the pack a code (or the browser languages) resolves to.
renderChart(element, spec)module functionDraw a bar, line, area, pie or scatter chart from your own numbers, without a grid.
changeTracker(initial)module functionFor 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)voidSwitch theme.
setFont({ size?, family? })voidChange font; family null restores the theme font.
setCellPadding(px | null) / getCellPadding()void / numberCell padding for every cell and header at once; null goes back to the theme / density value. getCellPadding returns the px in use.
setLocale(codeOrPack)voidSwitch UI language.
on(event, handler)() => voidSubscribe; returns an unsubscribe function.
destroy()voidRemove the grid and its listeners.