API
All public functions, options and types. The type definitions (dist/types) contain the same descriptions, so you can also read them in your editor.
# Exports
Copy import {
createGrid, Grid , VERSION , // grid
setLicenseKey, getLicenseState, // license
readXlsx, writeXlsx, downloadBlob, // Excel (without a grid)
formatDate, formatNumber, parseDate, // format helpers
LOCALES // built-in texts per language
} from 'horee-grid'
import 'horee-grid/dist/horee-grid.css'
Name Description createGrid(host, options)Creates a grid inside the host element and returns a Grid. Same as new Grid(host, options) VERSIONProduct version label ('b0.0.1') setLicenseKey(key)Sets the license key. License key getLicenseState()Promise<LicenseState>readXlsx(file)Blob · ArrayBuffer → Promise<{ name, rows: value[][] }[]>writeXlsx(sheet)XlsxSheet → Promise<Blob>downloadBlob(blob, fileName)Download as a file formatNumber(v, decimals?)Thousands separators (1234.5 → '1,234.5') formatDate(v, pattern?)Date → text ('20261115' → '2026-11-15') parseDate(text, pattern?)Text → 'yyyymmdd'. null for a date that does not exist LOCALESBuilt-in default texts per language { ko, en, ja, zh, es, pt } (each a Texts)
Types: Row, ColumnDef, GridOptions, GridState, ColumnState, SortItem, SortDir, FilterItem, FilterOp, CellInfo, CellChange, SelectOption, PasteResult, ImportResult, DataSource, PageRequest, PageResult, PageInfo, MenuItem, Texts, Locale, Align, LicenseState, LicenseReason, XlsxSheet, XlsxReadSheet, XlsxValue.
# GridOptions
The second argument of createGrid. Only columns is required.
# Data
Option Type Default Description columnsColumnDef[]— Column definitions. ColumnDef rowsRow[][]Rows. The grid writes values directly into these objects rowKeystring— Row identifier field. Used to keep selection and for select(key) bottomRowsRow[]— Fixed bottom rows (totals etc.) dataSourceDataSource— Server data. When given, sorting and filtering are left to the server. Server data emptyTextstringtext of locale Text shown when there are no rows
# Look
Option Type Default Description rowHeightnumber27Row height (px) headerHeightnumberrow height + 2 Height of one header row (px) rowNumbersbooleantrueRow number column at the far left lines'all' | 'row' | 'none''all'Body cell lines dateFormatstring'yyyy-mm-dd'Format for date columns. Text containing yyyy · mm · dd rowClass(row) => string | undefined— Class to add to a row locale'ko' | 'en' | 'ja' | 'zh' | 'es' | 'pt''ko'Language of menus, dialogs and the license notice. Texts textsPartial<Texts>texts of locale Only the grid texts you want to change. Texts
# Behavior
Option Type Default Description selection'none' | 'single' | 'multi''single'Row selection. multi adds checkboxes multiSortbooleantrueShift+click multi-sort columnResizebooleantrueColumn resizing columnMovebooleantrueColumn reordering (within the same fixed area) contextMenubooleantrueRight-click menu menuItems(items, at) => MenuItem[]— Customize the right-click menu. at = { column?, row? } readOnlybooleanfalseRead-only even if some columns are editable editOnClickbooleanfalseStart editing with a single click excelfalse | { fileName?, sheetName? }in the menu Right-click "Download Excel". fileName is text or a function, without the extension personalize{ onSave(state), onReset() }— Adds "Save layout" · "Reset layout" to the right-click menu
# Events
Option Arguments Called when onRowClick(row, ev)A row is clicked onRowDblClick(row, ev)A row is double-clicked onSelectionChange(rows)The selected rows change onCellChange(change: CellChange)The user changes a cell value (edit · check · Delete · paste) onPaste(result: PasteResult)The user pastes onSortChange(sort: SortItem[])The user changes the sort onFilterChange(filters: FilterItem[])The user changes the grid filters onColumnChange(columns: ColumnState[])The user changes column order, width or visibility onLoad(info: PageInfo)Loading server data starts or ends
on…Change events fire only for user actions . They do not fire when you call setSort, setValue and so on in code (except onSelectionChange, which also fires when you select in code).
# ColumnDef
# Basics
Property Type Default Description idstringfieldColumn identifier. Required when there is no field fieldstring— Key to read the value from the row titlestring— Header text headerTooltipstring— Header tooltip childrenColumnDef[]— Makes this a header group widthnumber120Width (px) flexnumber— Share of the leftover width minWidthnumber— Minimum width of a flex column align'left' | 'center' | 'right'by type Alignment fixed'left' | 'right'— Fixed to the left or right. On a group, applies to all columns below
Property Type Description type'text' | 'number' | 'date'Value type. Format, sorting, editor and Excel format follow it decimalsnumberDecimal places for number value(row) => anyCalculates the value instead of field format(cell: CellInfo) => stringDisplayed text. Takes precedence over the type format render(cell) => Node | string | nullDraws the cell yourself. null = default cellClassstring | (cell) => string | undefinedCell class tooltipboolean | (cell) => stringtrue = the displayed textcompare(a, b, rowA, rowB) => numberSort comparison exportValue(cell) => string | number | Date | nullValue exported to Excel
# User actions
Property Type Default Description sortablebooleantrueSort by clicking the header resizablebooleantrueResizing movablebooleantrueReordering
# Editing
Property Type Description editableboolean | (row) => booleanEditable cell editor'text' | 'number' | 'date' | 'select' | 'check'Editor. Follows type when omitted optionsSelectOption[] | (row) => SelectOption[]select list { value, label }checkValues[on value, off value]check values. Default [true, false]maxLengthnumberMaximum input length editText(cell) => stringInput text when editing starts parse(text, cell) => anyInput text → value. undefined = invalid setValue(row, value) => boolean | voidHow the value is written to the row. false = do not change
# Grid methods
# Data
Method Returns Description setRows(rows)Replaces the rows. Selection and active cell of the same rows (same object or same rowKey) are kept getRows()Row[]All original rows (including those hidden by filters, in the order given) getViewRows()Row[]Visible rows in display order setColumns(columns)Replaces the column definitions setBottomRows(rows)Replaces the fixed bottom rows. undefined = remove refresh()Recalculates and redraws after row values or conditions change from outside refreshRow(row)Redraws one row destroy()Removes the grid. Always call it when leaving the screen
# Sort · filter
Method Returns Description getSort() · setSort(sort)SortItem[]Sorting. Array order = priority getFilters() · setFilters(filters)FilterItem[]Grid filters setRowFilter(fn)Row filter function. null = none
# State
Method Returns Description getState() · setState(state)GridStateColumns, sort and filters together. null = initial look getColumnState() · setColumnState(state)ColumnState[]Column order, width and visibility getColumns(){ id, title, group, width, hidden }[]Column list (including hidden ones, in current order) setPersonalized(on)Personal layout marker
# Selection · navigation
Method Returns Description getSelectedRows()Row[]Selected rows select(key, scroll = true)Selects by rowKey value. Adds in multi clearSelection()Clears the selection setCurrent(key, scroll = true)"Current row" marker getActiveCell(){ row, column } | nullActive cell setActiveCell(row, column, scroll = true)Moves the active cell scrollToRow(index)Scrolls to the row at that display index
# Editing
Method Returns Description startEdit(mode = 'all')booleanStarts editing the active cell. 'all' = select all text, 'end' = cursor at the end stopEdit(cancel = false)booleanEnds editing. false if it cannot end because the value is invalid setValue(row, column, value)booleanChanges a cell value (with change mark). false if unchanged or not writable getChanges(){ row, original }[]Changed rows and the original values of changed cells hasChanges()booleanIs any cell changed? clearChanges()Clears the change marks (values stay)
# Clipboard · Excel
Method Returns Description copyText()stringThe range (or the active cell) as tab-separated text pasteText(text)PasteResultPastes tab-separated text into the range exportExcel(fileName?)Promise<void>Downloads .xlsx toExcel(rows?)Promise<Blob>Builds an .xlsx Blob importExcel(file)Promise<ImportResult>Reads the first sheet of an .xlsx as rows (does not put them in the grid)
# Server data
Method Returns Description reload()Promise<void>Fetches again from the first batch (search) getPageInfo()PageInfo{ loaded, total, loading }
# Types
Copy type Row = Record <string, any>
type SortDir = 'asc' | 'desc'
type FilterOp = 'eq' | 'ne' | 'gt' | 'ge' | 'lt' | 'le' | 'contains' | 'starts' | 'ends' | 'blank' | 'notBlank'
type Locale = 'ko' | 'en' | 'ja' | 'zh' | 'es' | 'pt'
interface SortItem { id: string; dir: SortDir }
interface FilterItem { id: string; op: FilterOp ; value: string }
interface ColumnState { id: string; width?: number; hidden?: boolean }
interface GridState { columns?: ColumnState []; sort?: SortItem []; filters?: FilterItem [] }
interface CellInfo {
value: any
row: Row
column: ColumnDef
rowIndex: number // display index; -1 for fixed bottom rows
bottom: boolean // is this a fixed bottom row?
}
interface CellChange { row: Row ; column: string; field?: string; oldValue: any; value: any }
interface SelectOption { value: any; label: string }
interface PasteResult {
changed: number // cells changed
skipped: number // cells skipped because they are not editable
invalid: { row: Row ; column: string; text: string }[] // cells with invalid values
overflow: number // lines not pasted for lack of rows
}
interface ImportResult { rows: Row []; invalid: { line: number; column: string; text: string }[] }
interface DataSource {
pageSize?: number // default 200
load: (req: PageRequest ) => Promise <PageResult >
confirmReload?: () => boolean | Promise <boolean>
onError?: (error: unknown) => void
}
interface PageRequest {
offset: number
limit: number // 0 = all
sort: { id: string; field?: string; dir: SortDir }[]
filters: { id: string; field?: string; op: FilterOp ; value: string }[]
}
interface PageResult { rows: Row []; total?: number; bottomRows?: Row [] }
interface PageInfo { loaded: number; total: number | null ; loading: boolean }
interface MenuItem { id: string; label: string; disabled?: boolean; separator?: boolean; action: () => void }
interface LicenseState {
ok: boolean
reason: 'ok' | 'dev' | 'none' | 'format' | 'signature' | 'domain' | 'expired' | 'version' | 'unsupported'
customer?: string
expires?: string // 'yyyy-mm-dd'
updates?: string // 'yyyy-mm-dd' update deadline (perpetual licenses)
}
# Texts
Choose the language with the locale option and change individual texts with texts. Below are the English (en) defaults. Other languages can be inspected via LOCALES.ko, LOCALES.ja and so on.
Key Default (en) emptyNo rows to show. menuHideColumntitle => Hide '${title}' (function)menuHideHide columns… menuFilterGrid filter… menuClearFilterClear filter menuSaveFormat · menuResetFormatSave layout · Reset layout menuExcelDownload Excel personalizedPersonal layout applied (marker tooltip) hideTitle · showAllHide columns · Show all (hide dialog) filterTitle · column · op · valueGrid filter · Column · Condition · Value (filter dialog) apply · clear · closeApply · Clear · Close ops11 condition names. { eq: '= Equals', contains: 'Contains', … }
# CSS variables
See Styling › CSS variables .