VibeFox JS Grid — Help
Overview
VibeFox JS Grid is a data grid for web applications: it shows tables of any size, lets users sort, filter, group, edit and select data, and exports and imports Excel, CSV and PDF. It is plain JavaScript with no dependencies and works with or without a framework.
You create a grid with one call, createGrid(target, options), and control it through the same methods as every VibeFox JS library: setData, setOptions, on, getState, setState, setTheme, destroy.
Key features
- Virtual scrolling of rows and columns: 100 000 rows × 200 columns render in about 1 ms per frame; an optional Web Worker mode sorts, filters and groups 1 million rows without blocking the page.
- Columns: types (text, number, date, boolean, select), pinning, resizing, reordering, multi-level column groups, automatic widths, heatmap columns, sparkline cells.
- Sorting by several columns, header filters with an Excel-like menu, a filter builder with AND / OR groups, and a quick search with a query syntax such as
price>100 city:london. - Grouping with aggregates, tree data, a totals row, a grouping panel, and a pivot mode with subtotals and totals.
- Inline editing with validation, built-in and custom editors (autocomplete, time, date-time, rich select, large text), change tracking, undo / redo, a fill handle, clipboard copy and paste (TSV, compatible with spreadsheets).
- Formulas in cells and computed columns (A1 and R1C1 references, about 180 built-in functions), conditional formatting (highlight rules, data bars, color scales, icon sets).
- Row drag and drop (also between grids), pinned rows, a new-row input, master / detail rows with nested grids, merged cells, variable and automatic row heights.
- Export to Excel (.xlsx with styles, groups, formulas), CSV, JSON and PDF; printing; import of .xlsx files with formulas, styles and merged cells.
- Server-side and infinite row models with a block cache, server grouping, server tree data and server pivot.
- Questions in natural language ("orders from Berlin over 1000, newest first") turned into filters, sorting, grouping and formatting; an optional adapter for your own language model.
- Nine ready-made table styles, every color and size as a CSS variable, light / dark and 16 more themes, right-to-left layout, full keyboard support and screen reader support.
Requirements
- A current web browser.
- No runtime dependencies. Nothing is loaded from the network: the library makes no requests of its own.
- Node.js is not needed in the browser. The ES module can be imported in Node (no DOM is touched at import), so the formula engine (
createFormulaEngine), the Excel helpers (createXlsx,readXlsx) and other functions without a DOM run on a server. Reading and writing compressed .xlsx files needsCompressionStream/DecompressionStream(browsers since 2023, Node 21.2+). - Optional: VibeFox JS Charts on the same page for full charts of cell ranges, VibeFox JS PDF on the same page for PDF documents and the PDF viewer. Without them the grid uses its own chart and its own PDF writer.
Installation
Files of the library
VibeFox JS Grid is a separate product with its own files. The whole JavaScript of the library is one file and the styles are one CSS file: a page needs exactly these two. The other files are optional.
| File | What it is |
|---|---|
vibefox-js-grid.global.js | The library for a classic <script> tag; defines one global variable, VibeFoxJSGrid. Minified: vibefox-js-grid.global.min.js. |
vibefox-js-grid.esm.js | The same code as an ES module. Minified: vibefox-js-grid.esm.min.js. |
vibefox-js-grid.css | All styles of the library, inside @layer vfjs; includes the themes light, dark and high-contrast. Minified: vibefox-js-grid.min.css. |
vibefox-js-themes.css | Optional theme pack: 18 ready-made themes (see Theming and styling). Minified: vibefox-js-themes.min.css. |
locales/vibefox-js-grid.<lang>.js | Optional language files, one for each language except English (see Localization and RTL). The same language as an ES module: .esm.js; as plain strings: .json. |
vibefox-js-grid.d.ts | TypeScript declarations (also vibefox-js-grid.esm.d.ts). |
*.js.map | Source maps. |
vibefox-js-grid-react.js, vibefox-js-grid-vue.js, vibefox-js-grid-svelte.js, vibefox-js-grid-jquery.js | Optional framework wrappers (each with its .d.ts). |
vibefox-js-grid-angular | Optional Angular package (Angular Package Format). |
vibefox-js-grid-wc.js | Optional Web Components wrapper (custom elements). |
Script tag
Link the CSS file and the script. The global variable VibeFoxJSGrid holds every export of the library. This also works from a file opened from disk (file://).
<link rel="stylesheet" href="vibefox-js-grid.css">
<script src="vibefox-js-grid.global.js"></script>
<script>
const grid = VibeFoxJSGrid.createGrid('#app', { data: rows });
</script>
ES module
Import the ES module file and link the CSS file. Browsers load modules only over http(s), not from file://.
<link rel="stylesheet" href="vibefox-js-grid.css">
<script type="module">
import { createGrid } from './vibefox-js-grid.esm.js';
const grid = createGrid('#app', { data: rows });
</script>
npm
The library is also prepared as an npm package named @vibefox/js-grid. Install it from the package folder (or its packed .tgz file) that you received, then import it by name. Bundlers take the CSS through the @vibefox/js-grid/css export.
npm install ./vibefox-js-grid
import { createGrid } from '@vibefox/js-grid';
import '@vibefox/js-grid/css';
Exports of the package: @vibefox/js-grid (ES module), @vibefox/js-grid/min, @vibefox/js-grid/global, @vibefox/js-grid/global.min, @vibefox/js-grid/css, @vibefox/js-grid/min.css, @vibefox/js-grid/themes, @vibefox/js-grid/themes.min.css, @vibefox/js-grid/locales/<lang>, @vibefox/js-grid/locales/<lang>.json. TypeScript finds the declarations by itself.
Framework wrappers
The wrappers are small separate files; the library works without them. Each wrapper needs only VibeFox JS Grid and its framework (a peer dependency). The wrappers do not load CSS: link vibefox-js-grid.css yourself.
| Framework | File | npm package | Supported versions |
|---|---|---|---|
| React | vibefox-js-grid-react.js | @vibefox/js-grid-react | React 16.8 and newer |
| Vue 3 | vibefox-js-grid-vue.js | @vibefox/js-grid-vue | Vue 3.3 and newer |
| Angular | vibefox-js-grid-angular | @vibefox/js-grid-angular | Angular 17 and newer |
| Svelte | vibefox-js-grid-svelte.js | @vibefox/js-grid-svelte | Svelte 3, 4 and 5 |
| jQuery | vibefox-js-grid-jquery.js | @vibefox/js-grid-jquery | jQuery 1.12 to 4.x |
| Web Components | vibefox-js-grid-wc.js | @vibefox/js-grid-wc | no framework |
The ES module wrappers import the library as @vibefox/js-grid. Without npm, map that name to vibefox-js-grid.esm.js in your bundler settings or in an import map. The jQuery wrapper takes the library from the global VibeFoxJSGrid.
Common rules of all wrappers: props / inputs are the options of the library (changed ones go to setData or one setOptions call); events are framework events with the same payload object as on(); the instance is available for every method; on the server (SSR) an empty container is rendered and the instance is created in the browser only. The option style (ready-made look) is the prop variant in React, Vue, Svelte and Angular, because style and className / class belong to the host element.
Web Components
Load vibefox-js-grid-wc.js after the library file. It defines the element <vfjs-grid> from the global VibeFoxJSGrid. Attributes are options in kebab-case (JSON for objects and arrays), properties are options, the methods of the component are methods of the element, events are CustomEvents named vfjsgrid:<event> with the payload in detail. The element uses the light DOM, so the CSS of the library and your page CSS apply as usual.
<link rel="stylesheet" href="vibefox-js-grid.css">
<script src="vibefox-js-grid.global.js"></script>
<script type="module" src="vibefox-js-grid-wc.js"></script>
<vfjs-grid id="g" height="300" row-id="id"></vfjs-grid>
<script>
const el = document.getElementById('g');
el.data = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
el.addEventListener('vfjsgrid:rowClick', (e) => console.log(e.detail.row));
</script>
With a bundler: import * as lib from '@vibefox/js-grid'; import { define } from '@vibefox/js-grid-wc'; define(lib);
Quick start
Plain HTML
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="vibefox-js-grid.css">
<script src="vibefox-js-grid.global.js"></script>
</head>
<body>
<div id="app"></div>
<script>
const rows = [
{ id: 1, name: 'Alice', city: 'Berlin', salary: 72000, joined: '2021-03-15', active: true },
{ id: 2, name: 'Bob', city: 'Paris', salary: 58000, joined: '2019-11-02', active: false },
{ id: 3, name: 'Carol', city: 'Berlin', salary: 91000, joined: '2022-06-20', active: true },
];
const grid = VibeFoxJSGrid.createGrid('#app', {
data: rows,
rowId: 'id',
height: 300,
columns: [
{ field: 'name', header: 'Name', editable: true },
{ field: 'city', header: 'City' },
{ field: 'salary', header: 'Salary', type: 'number', aggregate: 'sum', heatmap: true },
{ field: 'joined', header: 'Joined', type: 'date' },
{ field: 'active', header: 'Active', type: 'boolean', editable: true },
],
selection: { mode: 'row', multi: true, checkbox: true },
footer: true,
statusBar: true,
on: { rowClick: (e) => console.log('clicked', e.row.name) },
});
grid.setQuickFilter('salary>60000 city:berlin');
</script>
</body>
</html>
The columns may be left out: the grid takes them from the first row and detects the types (numbers, booleans, YYYY-MM-DD dates, text).
React
import { useRef, useState } from 'react';
import { VibeFoxJSGridReact } from '@vibefox/js-grid-react';
import '@vibefox/js-grid/css';
export function App() {
const [rows] = useState([{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]);
const [count, setCount] = useState(0);
const grid = useRef(null); // the VibeFoxJSGrid instance
return (
<>
<button onClick={() => grid.current.exportCSV()}>CSV</button>
<VibeFoxJSGridReact ref={grid} data={rows} rowId="id" height={300}
onSelectionChange={(e) => setCount(e.rows.length)} />
<p>Selected: {count}</p>
</>
);
}
Vue 3
<script setup>
import { ref } from 'vue';
import { VibeFoxJSGridVue } from '@vibefox/js-grid-vue';
import '@vibefox/js-grid/css';
const rows = ref([{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }]);
const q = ref('');
const grid = ref(null); // grid.value.instance is the VibeFoxJSGrid instance
</script>
<template>
<VibeFoxJSGridVue ref="grid" :data="rows" row-id="id" :height="300"
v-model:quick-filter="q" @selection-change="(e) => console.log(e.rows)" />
</template>
Angular
import { Component } from '@angular/core';
import { VibeFoxJSGridComponent } from '@vibefox/js-grid-angular';
@Component({
selector: 'app-root',
standalone: true,
imports: [VibeFoxJSGridComponent],
template: `
<vfjs-grid-ng #grid [data]="rows" rowId="id" [height]="300"
(selectionChange)="selected = $event.rows.length"></vfjs-grid-ng>
<button (click)="grid.instance?.exportCSV()">CSV</button>`,
})
export class AppComponent {
rows = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
selected = 0;
}
Link vibefox-js-grid.css in angular.json (styles) or in index.html. For NgModule applications import VibeFoxJSGridModule.
Svelte
<script>
import { vfjsGrid } from '@vibefox/js-grid-svelte';
let rows = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }];
let grid;
</script>
<div use:vfjsGrid={{ data: rows, rowId: 'id', height: 300, on: { ready: (e) => (grid = e.component) } }}
on:vfjsgrid:selectionChange={(e) => console.log(e.detail.rows)}></div>
jQuery
<script src="jquery.min.js"></script>
<link rel="stylesheet" href="vibefox-js-grid.css">
<script src="vibefox-js-grid.global.js"></script>
<script src="vibefox-js-grid-jquery.js"></script>
<script>
$('#grid').vfjsGrid({ data: rows, rowId: 'id', height: 300 })
.on('vfjsgrid:selectionChange', (e, payload) => console.log(payload.rows));
$('#grid').vfjsGrid('setSort', [{ field: 'name', dir: 'asc' }]);
const grid = $('#grid').vfjsGrid('instance');
</script>
Core concepts
Data model
The data is an array of plain objects, one per row (data option or setData(rows)). Each column shows one field of the row; dot paths such as 'address.city' read nested fields. The grid does not copy your rows: edits are written into the row objects.
Give every row a stable identity with rowId (a field name such as 'id', or a function (row) => id). The selection, unsaved changes, undo history, expanded rows and saved state refer to rows by id; with rowId: null (default) the grid assigns ids itself, and they do not survive setData with new objects.
Creating and destroying
const grid = VibeFoxJSGrid.createGrid('#app', { data: rows, rowId: 'id' }); // element or CSS selector
grid.setData(newRows); // replace the rows
grid.setOptions({ footer: true }); // patch options (deep merge)
grid.setOption('selection.mode', 'cell'); // one option by dot path
grid.getOption('height'); // read an option
grid.destroy(); // remove DOM and listeners
new VibeFoxJSGrid(target, options) is the same as createGrid. The grid fills its element. With the default height: null it takes exactly the height of its element; when the element has no height of its own, the rows area is 400 px high (the variable --vfjs-grid-min-height, see Theming and styling), with the pager and the status bar below it. A number (pixels) or a CSS size in height sets the height of the rows area instead. --vfjs-grid-min-height: 0 makes the grid as high as all its rows.
Events
Every event handler receives one payload object. Subscribe in the options (on: { rowClick: fn }) or later with on, once and off; on('*', (event, payload) => …) receives every event.
grid.on('cellChange', (e) => save(e.id, e.field, e.value));
grid.once('ready', (e) => console.log('ready', e.component));
grid.off('cellChange'); // remove every handler of the event
Every VibeFox JS component emits ready, dataChange, optionsChange, themeChange and destroy. Some events can be cancelled with preventDefault() in the handler: rowDragStart, rowDrop, rowAdd, rowRemove, fillStart, fill. The full list is in API reference.
State snapshots
getState() returns a JSON-safe snapshot of what the user changed: sort, filters, quick search, page, grouping, expanded groups and tree nodes, column widths / order / pinning / visibility, selection, active cell, scroll position, undo history, table style, column groups, row heights, master / detail rows, tool panel, pivot layout, computed column formulas, conditional formatting rules and range charts. Save it (for example in localStorage) and give it back with setState(state); a partial state is accepted.
localStorage.setItem('orders-grid', JSON.stringify(grid.getState()));
grid.setState(JSON.parse(localStorage.getItem('orders-grid')));
Plugins
grid.use(plugin, options) calls plugin.install(grid, options): a simple way to package your own additions.
Columns
Column definitions
The columns option is an array of column objects (a plain field name string is accepted too). Without it the columns are taken from the first row.
columns: [
{ field: 'name', header: 'Name', width: 200, pin: 'left' },
{ field: 'price', type: 'number', decimals: 2, align: 'right', aggregate: 'sum' },
{ field: 'date', type: 'date', dateFormat: 'DD.MM.YYYY' },
{ field: 'status', type: 'select', options: ['new', 'work', 'done'], editable: true },
{ field: 'address.city', header: 'City', hidden: true },
]
| Option | Type | Default | Description |
|---|---|---|---|
field | string | required | Field of the row; dot paths are supported. |
header | string | title-cased field | Header text. |
type | 'text' | 'number' | 'date' | 'boolean' | 'select' | detected | Drives display, sorting, filtering and the editor. |
width, minWidth, maxWidth | number (px) | from CSS variables | Column width limits. Defaults: 150 px for text, 110 for numbers, 120 for dates, 90 for booleans, min 50, max 800 (--vfjs-grid-column-width and related variables). |
align | 'left' | 'right' | 'center' | by type | Cell alignment. |
sortable, filterable, resizable, editable | boolean | grid option | Per-column override of the grid options of the same name. |
pin | 'left' | 'right' | null | null | Pinned side. |
hidden | boolean | false | Hidden column. |
formatter | (value, row) => string | null | Own cell text. |
validate | (value, row) => true | string | null | Editor validation: true = valid, a string = error text. |
options | array of values or { value, label } | null | Values of a 'select' column. |
aggregate | 'sum' | 'avg' | 'min' | 'max' | 'count' or (values, rows) => value | null | Aggregate of group rows and the totals row. |
heatmap | boolean | false | Background color by value (numeric columns). |
dateFormat | string | 'YYYY-MM-DD' | Date format; tokens YYYY MM DD HH mm ss. |
decimals | number | — | Decimal places of numbers. |
cellClass | string or (value, row) => string | null | Extra CSS class of the cells. |
renderer | function, object or class | null | Own cell content (see Cell renderers and editors). |
editor | type name, popup editor name, function, object or class | by type | Own or built-in editor. |
editorOptions | object | null | Options of the editor. |
filter | 'text' | 'number' | 'date' | 'set' | by type | Kind of the header filter; 'set' = list of values. |
toolPanel | boolean | true | Listed in the columns tool panel. |
groupable | boolean | true | Rows may be grouped by this column. |
groupShow | 'open' | 'closed' | null | null | Shown only when the parent column group is open / closed. |
wrapText, autoHeight, wrapHeaderText | boolean | grid option | Text wrapping and automatic row height for this column. |
rowDrag | boolean | false | The row drag handle is in this column. |
colSpan, rowSpan | function (or true for rowSpan) | null | Merged cells (see Rows and data). |
formula | string | null | Computed column, for example '=[@price]*[@qty]'. |
sparkline | true, a type or an options object | null | Small chart in the cell. |
excel | { numFmt, style, headerStyle, width, value } | null | How the column is exported to Excel. |
pdf | { value, width, align } | null | How the column is printed / exported to PDF. |
Changing columns at run time
grid.setColumns(columns); // replace the definitions
grid.getColumns(); // normalized columns in the current order
grid.setColumnWidth('name', 240);
grid.autoSizeColumns(); // fit every column (or one: autoSizeColumns('name'))
grid.pinColumn('name', 'left'); // 'left' | 'right' | null
grid.hideColumn('city'); // hideColumn(field, false) or showColumn(field) shows it
grid.hideColumns(['a', 'b']); // several with one repaint
grid.moveColumn('price', 'name', true); // move after 'name'
Users resize columns by dragging the header edge, move them by dragging the header (reorderable), and pin, hide and auto-size them from the context menu. Events: columnResize, columnReorder, columnPin, columnHide.
Column groups (multi-level headers)
A definition with children is a column group: it gets a header cell above its columns. Groups can be nested to any depth.
columns: [
'name',
{ header: 'Address', groupId: 'addr', collapsible: true, children: [
'city',
{ field: 'street', groupShow: 'open' }, // only while the group is open
] },
{ header: 'Sales', marryChildren: true, children: ['q1', 'q2', 'q3', 'q4'] },
]
Group options: header, children, groupId, collapsible, expanded (default true), marryChildren (the columns stay together), headerClass, align, groupShow, wrapHeaderText. Methods: getColumnGroups(), setColumnGroupExpanded(groupId, expanded), toggleColumnGroup(groupId), moveColumnGroup(groupId, targetField, after). Events: columnGroupToggle, columnGroupClick.
Columns tool panel and grouping panel
sideBar: true adds a side panel listing every column: show / hide (groups have a three-state check box), search, pin, and drag to reorder. Options: { position: 'right' | 'left', open, width, search, pin, groups, toggle }. Methods: openToolPanel(), closeToolPanel(), toggleToolPanel(), isToolPanelOpen(); event toolPanelChange. Set toolPanel: false on a column to leave it out.
groupPanel: true adds a bar above the grid: drop a column header there to group the rows by it; the chips are the grouping levels (drag to reorder, × or Delete removes). Columns with groupable: false cannot be dropped there.
Cell renderers and editors
Renderers
column.renderer draws the cell content. It may be a function that returns an HTML string or a DOM node, a lifecycle object, or a class.
columns: [
// HTML string: escape the values you insert
{ field: 'name', renderer: (p) => `<b>${p.escape(p.value)}</b>` },
// lifecycle object: one mounted instance per visible cell
{ field: 'progress', renderer: {
mount(el, p) { const bar = document.createElement('progress'); bar.max = 100; bar.value = p.value; el.append(bar); return bar; },
update(el, p, bar) { bar.value = p.value; }, // return false to mount again
destroy(el, bar) { bar.remove(); },
} },
]
The parameters (GridCellParams) are value, formatted (display text), row, id, field, column, rowIndex, grid, escape and pinned. An error thrown by your renderer is logged and the grid keeps rendering.
Framework components in cells
The React, Vue, Svelte and Angular wrappers export cellRenderer(Component) and cellEditor(Component), which turn a component into a renderer / editor object. Keep the column definitions stable (a constant, or useMemo in React).
import { VibeFoxJSGridReact, cellRenderer } from '@vibefox/js-grid-react';
const Badge = ({ value }) => <span className="badge">{value}</span>;
const columns = [{ field: 'status', renderer: cellRenderer(Badge) }]; // outside the component
Editors
Editing is on when the grid option editable or the column option editable is true. Users start editing with a double click, Enter, F2 or by typing; Enter / Tab commit, Esc cancels. The built-in editor follows the column type. column.validate returns true or an error text; an invalid value is not committed.
Built-in popup editors (column.editor) with their editorOptions:
| Editor | What it does | Main editorOptions |
|---|---|---|
'autocomplete' | Text input with a list of suggestions, local or from your async source. | values, source, valueField, labelField, filter, delay, minChars, maxItems, strict, openOnFocus, autoHighlight, template |
'richSelect' | List with search, optional several values. | values, source, multiple, separator, search, template |
'time' | Time list. | step, min, max, seconds, hour12, valueFormat |
'datetime' | Calendar with a time list. | timeStep, min, max, seconds, hour12, valueFormat |
'largeText' | Text area in a popup. | rows, cols, maxLength |
{ field: 'customer', editor: 'autocomplete', editorOptions: {
source: async (query, { signal }) => (await fetch(`/api/customers?q=${encodeURIComponent(query)}`, { signal })).json(),
minChars: 2, strict: true,
} }
Own editors: column.editor may be a function (params) => element (the element's value is read and parsed by the column type), or an object / class with mount, getValue, focus, destroy and keepOnBlur. The parameters (GridEditorParams) include value, row, field, initialChar (the typed character), options, commit() and cancel().
{ field: 'qty', editor: {
mount(el, p) { const input = document.createElement('input'); input.type = 'range'; input.value = p.value; el.append(input); return input; },
getValue(el, input) { return Number(input.value); },
focus(el, input) { input.focus(); },
} }
Rows and data
Adding, removing and changing rows
grid.addRows({ id: 4, name: 'Dan' }); // at the end; { index } or { parentId } for tree data
grid.removeRows([2, 3]); // by id
grid.setCellValue(1, 'salary', 80000); // change tracking and undo apply, validate does not
grid.batchEdit((g) => { g.setCellValue(1, 'a', 1); g.setCellValue(2, 'a', 2); }); // one undo step, one repaint
grid.refresh(); // recompute after you changed row objects yourself
addRows and removeRows are one undo step each and emit the cancelable events rowAdd and rowRemove.
Tree data
tree: true shows nested rows: children are in the field childrenField (default 'children'). Nodes start expanded (treeDefaultExpanded). Users expand and collapse with the toggle or → / ←; expandAll() and collapseAll() do it for every node; the event is treeToggle.
VibeFoxJSGrid.createGrid('#app', { tree: true, rowId: 'id', data: [
{ id: 1, name: 'Europe', children: [{ id: 2, name: 'Berlin' }, { id: 3, name: 'Paris' }] },
] });
Row heights and text wrapping
All rows have the same height by default: rowHeight: null takes the CSS variable --vfjs-grid-row-height (30 px at normal density); a number sets it in pixels. For rows of different heights pass a function (params) => px | null; virtual scrolling keeps working.
rowHeight: (p) => (p.kind === 'group' ? 40 : p.row?.important ? 48 : null)
wrapText: true wraps cell text onto several lines, autoRowHeight: true grows the rows to fit their cells (measured in the DOM), wrapHeaderText: true wraps header text; all three also exist per column. setRowHeight(rowId, px) fixes one row, getRowHeight(rowId) reads it, resetRowHeights() measures again.
Pinned rows and the new-row input
pinnedTopRows and pinnedBottomRows show rows that do not scroll and are not sorted or filtered: an array of row objects, or a function of the filtered rows (useful for totals). setPinnedRows(side, rows) and getPinnedRows(side) change and read them.
pinnedBottomRows: ({ rows }) => [{ name: 'Total', salary: rows.reduce((s, r) => s + r.salary, 0) }]
newRow: true adds an input row (pinned at the top, or { position: 'bottom' }): Enter in its last editable cell adds the row. Options position, values (defaults of a new row, object or function), insert ('start' | 'end'), parentId. Methods getNewRow(), addNewRow(), resetNewRow().
Row drag and drop
rowDrag: true shows a drag handle in the first data column (or in the column with rowDrag: true). Options: handle (false = drag the whole row; touch: long press), column, multi (drag the selected rows), managed (false = events only, you move the rows), copy, keyboard (Alt+↑ / Alt+↓, tree: Alt+→ / Alt+←), autoScroll, longPress. In grouped rows a drop changes the group values; in tree data it changes the parent.
Between two grids: link(source, 'rowDrag', target, 'receiveRowDrag'), or source.addRowDropTarget(target). Any element can be a drop target too (addRowDropTarget(element, { onDrop, remove }), for example a trash bin with remove: true). Events: rowDragStart (cancelable), rowDrag, rowDrop (cancelable; position, parentId, group), rowDragEnd.
const { link } = VibeFoxJSGrid;
const unlink = link(gridA, 'rowDrag', gridB, 'receiveRowDrag'); // drag rows from A to B
gridB.on('rowDrop', (e) => { if (e.rows.some((r) => r.locked)) e.preventDefault(); });
Master / detail
masterDetail adds an expandable detail row under each master row: your own content (renderer) or a nested grid (grid + rows).
masterDetail: {
rows: 'orders', // field of the master row with the detail rows
grid: { columns: ['date', 'item', { field: 'total', type: 'number' }], height: 200 },
isMaster: (row) => row.orders?.length > 0,
}
Other options: height ('auto', px or a function), estimate, toggle, column, keepState. Methods: expandDetail(rowId), collapseDetail(rowId), toggleDetail(rowId), isDetailExpanded(rowId), getExpandedDetails(), getDetailGrid(rowId), getDetailElement(rowId). Events: detailToggle, detailGridReady.
Merged cells
column.colSpan(params) returns how many columns to the right a cell covers; column.rowSpan(params) how many rows below it covers, or rowSpan: true merges consecutive equal values. Spans stay inside one pinned zone and do not cross group rows, detail rows or pages. Merged cells are exported to Excel as merges and printed in the PDF.
{ field: 'region', rowSpan: true },
{ field: 'note', colSpan: (p) => (p.row.isHeader ? 3 : 1) }
Pagination and the status bar
pagination: { pageSize: 100, pageSizes: [50, 100, 250, 500, 1000] } shows pages instead of endless scrolling (default page size 100). Methods: setPage(page) (zero-based), getPage(), getPageCount(); event pageChange. statusBar: true shows the row count, the selection and the number of unsaved changes; emptyText is shown when there are no rows.
Editing and change tracking
Change tracking
With changeTracking: true (default) edited cells get a marker and the grid keeps a list of unsaved changes: getChanges() returns [{ id, row, field, oldValue, value }], acceptChanges() clears the list after you saved, revertChanges() restores the old values (one undo step). The event changesChange reports the count.
grid.on('changesChange', (e) => (saveButton.disabled = e.count === 0));
saveButton.onclick = async () => {
await fetch('/api/rows', { method: 'POST', body: JSON.stringify(grid.getChanges()) });
grid.acceptChanges();
};
Programmatic editing: beginEdit(rowIdOrIndex, field), endEdit(commit), setCellValue(rowId, field, value), getCellValue(rowId, field). Events: editStart, editEnd (cancelled), cellChange (every written value).
Undo and redo
Edits, paste, fill, clearing, row moves, added and removed rows are undo steps (undo: true, up to undoLimit: 100 steps). Keys: Ctrl+Z, Ctrl+Y or Ctrl+Shift+Z. Methods: undo(), redo(), canUndo(), canRedo(), clearHistory(); event historyChange. The history is part of getState() and is restored when the rows keep their ids.
Fill handle
In cell selection mode (selection: { mode: 'cell' }) a handle at the corner of the selected range fills editable cells: one number is copied, other values continue their series (numbers, dates, "Item 1", week days and months of the locale, your own lists); Ctrl switches between copy and series. Dragging the handle back into the range clears the cells that leave it. Options (fillHandle): mode ('auto' | 'copy' | 'series'), direction ('both' | 'vertical' | 'horizontal'), lists, autoScroll. Keys Ctrl+D / Ctrl+R fill down / right; fillSelection(direction, { count, mode }) does the same from code. Events: fillStart, fill (cancelable; the values may be changed), fillEnd.
fillHandle: { lists: [['Low', 'Medium', 'High']] }
Selection and clipboard
The selection option: mode ('row' default, 'cell', 'none'), multi (default true), checkbox (a check box column), cellRanges (drag cell ranges in cell mode, default true). Click selects, Ctrl+click adds, Shift+click selects a range, Ctrl+A selects all.
grid.setSelection([1, 3]); // by id
grid.getSelection(); // { ids, rows, range }
grid.getSelectedRows();
grid.selectAll(); grid.clearSelection();
grid.setCellRange({ from: { id: 1, field: 'name' }, to: { id: 3, field: 'salary' } }); // cell mode
grid.getCellRange(); // { from, to, rows, fields }
grid.copySelection(true); // copy as TSV with headers
Ctrl+C copies the selection as tab-separated text (pasted into spreadsheets as cells); Ctrl+V pastes such text into editable cells (one undo step); Delete clears the selected cells. Events: selectionChange, copy, paste. The browser allows clipboard access only on secure pages (https or localhost).
Sorting, filtering and search
Sorting
A header click sorts ascending, descending, then not at all; Shift+click adds a column to the sort (multiSort). Sorting follows the column type; text is compared with the locale collation, empty values come last.
grid.setSort([{ field: 'city', dir: 'asc' }, { field: 'salary', dir: 'desc' }]);
grid.getSort();
grid.toggleSort('name', true); // like Shift+click
Header filters
Each filterable column has a filter button. The default menu (filterMenu: 'excel') has sorting, up to two conditions joined by AND / OR, and the list of values with search and "select all" (dates as a year → month → day tree); filterMenu: 'simple' shows one condition or the value list.
grid.setFilter('salary', { type: 'number', op: '>=', value: 60000 });
grid.setFilter('name', { type: 'text', op: 'startsWith', value: 'A' });
grid.setFilter('joined', { type: 'date', op: 'between', value: '2021-01-01', value2: '2021-12-31' });
grid.setFilter('city', { type: 'set', values: ['Berlin', 'Paris'] });
grid.setFilter('active', { type: 'boolean', op: 'isTrue' });
grid.setFilter('name', { type: 'text', join: 'or', conditions: [{ op: 'contains', value: 'a' }, { op: 'endsWith', value: 'n' }] });
grid.setFilter('city', null); // remove
grid.getFilters(); grid.clearFilters();
Text operators: contains, notContains, equals, notEquals, startsWith, endsWith, blank, notBlank. Number and date operators: =, !=, >, >=, <, <=, between, blank, notBlank. Boolean: isTrue, isFalse, blank, notBlank.
Filter builder
The filter builder (context menu item, or showFilterBuilder()) combines conditions in nested AND / OR groups, each group can be negated. The model is plain JSON:
grid.setFilterModel({ op: 'and', rules: [
{ field: 'city', op: 'equals', value: 'Berlin' },
{ op: 'or', rules: [{ field: 'salary', op: '>', value: 80000 }, { field: 'active', op: 'isTrue' }] },
] });
grid.getFilterModel(); grid.setFilterModel(null);
The operators of a rule follow the kind of its column, as in the header filters; in and notIn with values work for value-list columns (type: 'select' or filter: 'set'). A rule the column cannot take is left out. The header filters and the filter model apply together (AND). Option filterBuilder: { maxDepth } limits the nesting; filterBuilder: false removes it. The event filterChange carries filters, quickFilter and filterModel.
Quick search and query syntax
setQuickFilter(text) (or the quickFilter option) keeps the rows that contain every word of the text in their visible cells. With smartQuery: true (default) a word can also address a column by its field or header:
| Query | Meaning |
|---|---|
city:berlin | The column contains "berlin". |
city=berlin | The column equals "berlin". |
salary>60000, salary<=100, qty!=0 | Number or date comparison (> < >= <= = !=). |
"new york" | Exact text with spaces (no column syntax inside quotes). |
salary>60000 city:berlin | Several terms: all must match. |
A column name may be a field, a header or the start of a field; matching is case-insensitive.
Grouping, totals and pivot
Row grouping
grid.setGroupBy(['city', 'status']); // groupBy option; [] removes the grouping
grid.getGroupBy();
grid.expandAll(); grid.collapseAll();
Group rows show the group value, the row count and the aggregates of the columns with aggregate. Groups start expanded (groupDefaultExpanded). Users group from the context menu, with the key G in a header, or with the grouping panel (groupPanel: true). Events: groupChange, groupToggle.
Totals row
footer: true adds a totals row with the aggregate of every column over the filtered rows: 'sum', 'avg', 'min', 'max', 'count' or a function (values, rows) => value.
Column statistics
getColumnStats(field) returns count, empty, distinct, min, max, sum, avg, median, a 10-bin histogram and the five most frequent values (topValues). The context menu shows the same statistics in a dialog.
Pivot mode
pivot turns the grid into a pivot table: row fields, column fields and value fields with aggregates, subtotals and grand totals. With pivot: true users build the layout in the side bar and the grouping panel (keys R, C, V, F in the panel).
VibeFoxJSGrid.createGrid('#app', { data: sales, sideBar: true, pivot: {
rows: ['region', 'city'],
columns: [{ field: 'date', dateGroup: 'quarter' }],
values: [{ field: 'amount', aggregate: 'sum' }, { field: 'amount', aggregate: 'avg', header: 'Average' }],
rowTotals: 'bottom', columnTotals: 'right',
} });
Pivot options: enabled, rows, columns, values, filters, aggregates (own aggregates by name: a function or { init, add, result, label }), rowTotals, columnTotals, rowSubtotals, columnSubtotals, expanded, columnsExpanded, labelHeader, labelWidth, valueWidth. A row / column field may have dateGroup ('year' | 'quarter' | 'month' | 'day' | 'date'), key, label, sort, header. Built-in aggregates (PIVOT_AGGREGATES): sum, count, avg, min, max, distinct.
Methods: setPivot(patch), getPivot(), setPivotMode(on), isPivotMode(), setPivotFilter(field, filter), showPivotFilter(field), getPivotResult(), getPivotCell(rowId, field) (with the source rows of the cell). Events: pivotChange, pivotCompute. The pivot result is read-only and is exported to Excel, CSV and PDF as shown.
Formulas
Computed columns
A column with formula computes one formula for every row (read-only). [@field] is a field of the same row, [field] the whole column; A1 text written for the first row works too ('=C1*D1', relative references follow each row). Computed columns work without the formulas option.
columns: ['item', { field: 'price', type: 'number' }, { field: 'qty', type: 'number' },
{ field: 'total', type: 'number', formula: '=[@price]*[@qty]', aggregate: 'sum' }]
setColumnFormula(field, formula) changes it at run time (one undo step, event formulaChange); getColumnFormula(field) reads it.
Formulas in cells
With formulas: true every cell value that is a text starting with = is a formula: '=SUM(C1:C10)', '=IF([@qty]>10,"bulk","")'. Column letters follow the column definitions (A = the first), row numbers the data rows (1 = the first). The editor colors references, completes function names (Tab) and inserts a reference when you click a cell. Errors show as #DIV/0!, #N/A, #VALUE!, #REF!, #NAME?, #NUM!, #NULL! and #CIRC! (circular reference).
formulas: {
cells: true,
referenceStyle: 'A1', // or 'R1C1' in the editor; stored formulas are always A1
functions: { MARGIN: (price, cost) => (price - cost) / price },
names: { RATE: 0.2, Prices: '=$C$1:$C$100' },
}
formulas.locale sets the separators of the editor (for 'ru': ; between arguments and a decimal comma; default: the grid locale); function names are English in every locale. Methods: getCellFormula(rowId, field), getCellValue(rowId, field), evaluateFormula(formula, at), calculate(), recalculate() (volatile functions such as NOW, TODAY, RAND), registerFunction(name, fn), getFormulaEngine().
Formula engine without a grid
The engine has no DOM and also runs in Node: createFormulaEngine(options) / new FormulaEngine(options), with addSheet(name, adapter), value(sheet, row, col), evaluate(sheet, formula), check(formula) and more. Helpers: registerFormulaFunction(name, fn, options) (for every grid of the page), unregisterFormulaFunction(name), parseFormula, shiftFormula, formulaToR1C1, formulaToA1, localizeFormula, delocalizeFormula, FORMULA_FUNCTIONS (names of the built-in functions), FormulaError.
const { createFormulaEngine } = VibeFoxJSGrid;
const data = [[2, 3], [4, 5]];
const engine = createFormulaEngine();
const sheet = engine.addSheet('S', { rows: () => data.length, cols: () => 2, get: (r, c) => data[r][c] });
engine.evaluate(sheet, '=SUM(A1:B2)'); // 14
Conditional formatting
conditionalFormats is a list of rules in priority order (the first wins a conflict, stopIfTrue stops the rules after it). Users edit them in a dialog (context menu "Conditional formatting…", or showConditionalFormats(field)). The rules are exported to Excel as conditional formatting and drawn in the PDF.
conditionalFormats: [
{ fields: ['salary'], type: 'cell', op: '>', value: 80000, style: { preset: 'good' } },
{ fields: ['city'], type: 'text', op: 'equals', value: 'Paris', style: { bg: '#fff3c4', bold: true } },
{ fields: ['joined'], type: 'date', period: 'thisYear', style: { preset: 'accent' } },
{ fields: ['salary'], type: 'top', count: 10, percent: true, style: { preset: 'bold' } },
{ fields: ['salary'], type: 'formula', formula: '=[@salary]>[@limit]', style: { preset: 'bad' } },
{ fields: ['score'], type: 'dataBar', gradient: true },
{ fields: ['growth'], type: 'colorScale', colors: ['#f8696b', '#ffeb84', '#63be7b'] },
{ fields: ['rating'], type: 'iconSet', icons: 'stars3' },
]
Rule types: cell (op: > >= < <= = !=, between, notBetween; value, value2), text (contains, notContains, startsWith, endsWith, equals, notEquals), date (period: today, yesterday, tomorrow, last7Days, this / last / next week, month, quarter, year such as thisMonth or lastQuarter), top / bottom (count, percent), aboveAverage / belowAverage (equal, stdDev), duplicate, unique, blank, notBlank, formula, function (test(value, row, info) returns true or a style), and the visual types dataBar (color, negativeColor, axisColor, gradient, axis, min, max, border, showValue), colorScale (colors, stops, three) and iconSet (icons, thresholds, reverse, showValue).
A style is a preset (bad, good, neutral, accent, badText, goodText, bold; colors are the CSS variables --vfjs-grid-cf-*) or own values: bg, fg, bold, italic, underline, strike, border, className. Icon sets (CF_ICON_SETS): arrows3, arrows4, arrows5, traffic3, signs3, symbols3, flags3, stars3, rating4, rating5, quarters5, triangles3. Other rule fields: id, enabled, scope ('filtered' or 'all' rows for the statistics), now.
Methods: setConditionalFormats(rules), getConditionalFormats(), addConditionalFormat(rule, index) (returns the id), updateConditionalFormat(id, patch), removeConditionalFormat(id), clearConditionalFormats(), getCellFormat(rowId, field), showConditionalFormats(), hideConditionalFormats(); event conditionalFormatChange. conditionalFormatMenu: false removes the context menu item.
Own cell styles
setCellStyle(rowId, field, style) gives one cell its own style (bold, italic, underline, strike, color, fill, align, numFmt); getCellStyle and clearCellStyles read and remove them. Styles imported from .xlsx files use the same mechanism and are written back by the Excel export.
Sparklines and range charts
Sparkline cells
column.sparkline draws a small chart of the cell value (an array of numbers or a text such as '1;2;3') or of several fields of the row. Types: line (true), area, column, winloss, bullet.
{ field: 'trend', header: 'Q1–Q4', sparkline: { type: 'column', fields: ['q1', 'q2', 'q3', 'q4'], markers: true } },
{ field: 'progress', sparkline: { type: 'bullet', target: 'goal', ranges: [50, 80, 100] } }
Options: type, fields, min, max, scale ('row' or 'column'), markers, labels, tooltip, target, ranges, decimals. Colors: the CSS variables --vfjs-grid-spark-*.
Charts of a cell range
Users select a cell range and choose "Chart from range…" in the context menu; from code call createRangeChart(options). The chart follows edits of the grid (live) and is part of getState().
// rows: row ids (default: the selected cell range, else the selected rows); null when there is no range
const chart = grid.createRangeChart({ rows: [1, 2, 3], fields: ['q1', 'q2', 'q3'], type: 'column', title: 'Sales' });
chart.setType('line');
const svg = chart.toSVG({ width: 600, height: 300 });
Options: rows, fields, type ('column' | 'bar' | 'line' | 'pie'), seriesBy ('auto' | 'columns' | 'rows'), categoryField, target (an element instead of the panel in the grid), engine, title, live, chartOptions. The chart object has getData(), setType(), setSeriesBy(), setRange(), update(), toSVG(), state(), setPanelSize(), destroy(), on() / off(). Grid methods: getRangeChartData(), getRangeCharts(), destroyRangeCharts(); events rangeChartCreate, rangeChartDestroy. The option rangeChart sets defaults, rangeChart: false removes the menu item.
Range charts work on their own with the grid's built-in SVG chart. If VibeFox JS Charts is also on the page (its file loaded), engine: 'auto' (default) draws a full VibeFox JS Charts chart; chart.chart is that chart.
Export, import and printing
CSV and JSON
grid.exportCSV('orders.csv'); // the filtered rows; download
grid.exportCSV('selected.csv', { rows: 'selected' });
const text = await grid.getCSV({ rows: 'filtered', numbers: 'raw' });
grid.exportJSON('orders.json');
CSV options: rows ('filtered' | 'selected' | 'all' | 'loaded' or an array), pinned, spans ('empty' | 'fill'), numbers ('locale' or 'raw'). The delimiter is ;. getViewData() returns the filtered and sorted rows; getAllRows() every row of the current query (also from a server).
Excel export
await grid.exportXlsx('orders.xlsx', { title: 'Orders 2026', rows: 'view', footer: true });
const bytes = await grid.getXlsx(); // Uint8Array, no download
// several grids in one workbook (createXlsx is exported by the library)
const file = await VibeFoxJSGrid.createXlsx([gridA.getXlsxSheet({ name: 'A' }), gridB.getXlsxSheet({ name: 'B' })]);
The file keeps the header style, frozen header and left-pinned columns, an auto filter, column widths, number and date formats, group rows as Excel outline levels, group and total rows as SUBTOTAL formulas, column groups, merged cells, heatmap fills, conditional formatting and the formulas of the grid. Sheet options (GridXlsxSheetOptions): name, title, rows ('view' | 'filtered' | 'all' | 'selected' or an array), columns, groups, footer, formulas, header, freeze, autoFilter, heatmap, heatmapColor, headerStyle, groupStyle, footerStyle, titleStyle, cellStyle, rightToLeft (a right-to-left sheet; default: the direction of the grid), columnGroups, spans, spanValues, pinned, pinnedStyle, conditionalFormats. Workbook options: sheets (one sheet per item; { kind: 'stats' } = column statistics), extraSheets, creator, compress. Per column: column.excel.
Excel import
input.onchange = async () => {
const result = await grid.importXlsx(input.files[0], { sheet: 'ask', styles: true });
if (result) console.log(result.rows.length, result.warnings);
};
The first non-empty row (or headerRow) is the header; headers are matched to columns by header text or field, unknown headers become new columns (columns: 'merge', default) or replace them ('replace'). Options: sheet (name, index or 'ask' for a dialog), formulas, styles, merges, conditionalFormats, append, header, headerRow, signal, onProgress. The result has rows, columns, added, sheet, sheets, warnings (what was not imported: charts, images, comments…), merges, formulas, ms. getXlsxSheets(file) lists the sheets; events import, importProgress.
PDF and printing
await grid.exportPDF('orders.pdf', { title: 'Orders', pageSize: 'A4', orientation: 'auto', footerText: 'Confidential' });
const pdfBytes = await grid.getPDF({ rows: 'selected' });
await grid.print({ colors: 'print' }); // opens the print dialog
await grid.previewPDF('#preview'); // preview in an element
The pages are vector drawings of the grid: header repeated on every page, group rows, totals, merged cells, conditional formatting, sparklines. Options (GridPdfOptions): filename, rows, columns, pageSize ('A3' | 'A4' | 'A5' | 'Letter' | 'Legal' | 'Tabloid' or [width, height] in pt), orientation, margin, scale, fit ('width', null or { across }), minScale, repeatPinned, pageOrder, title, footerText, pageNumbers, header, columnGroups, groups, expandGroups, pinned, footer, spans, striped, rowHeight, colors ('grid' or 'print'), background, frame, pages, author, subject, embedFonts, rtl (right-to-left pages; default: the direction of the grid). getPrintLayout() returns the page layout without drawing (with rtl).
Text outside the standard PDF fonts (Cyrillic and others) stays selectable; to show it in your font, pass your font files with embedFonts (.ttf, .otf or .woff; true = the @font-face files of the page). With a font that has the letters, Arabic, Hebrew and Hindi text is written as on the screen: right to left where needed, Arabic letters joined, Devanagari syllables built. The library ships no fonts.
Right-to-left exports
The exports of a right-to-left grid (rtl: true or dir="rtl") follow the screen:
- PDF and printing: the first column on the right,
pin: 'left'columns on the right andpin: 'right'on the left (also when repeated on every page), column group headers, group rows, totals, tree indents, conditional format icons and data bars mirrored; text right, numbers left; the title andfooterTexton the right, page numbers on the left. The optionrtlofgetPDF,exportPDF,print,getPrintLayout,previewPDF,toPdfDocumentandaddToPdfDocumentdefaults to the direction of the grid:rtl: falsegives left-to-right pages of a right-to-left grid,rtl: trueright-to-left pages of a left-to-right grid. - Excel: the sheet is a right-to-left sheet (
rightToLeftdefaults to the direction of the grid;rightToLeft: falsewrites a normal sheet), column A is the first column, and the cells are aligned as on the screen (text right, numbers left).
const he = VibeFoxJSGrid.createGrid('#app', { data: rows, rtl: true });
await he.exportPDF('orders.pdf', { embedFonts: true }); // first column on the right
await he.exportXlsx('orders.xlsx'); // right-to-left sheet
const ltr = await he.getPDF({ rtl: false }); // left-to-right pages
console.log(he.getPrintLayout().rtl, he.getPrintLayout({ rtl: false }).rtl); // true false
PDF export and printing work on their own. If VibeFox JS PDF is also on the page (its file loaded), toPdfDocument() returns a VibeFox JS PDF document of the pages, addToPdfDocument(doc) appends them to an existing one (a tagged, accessible table when the document is created with pdfua: true), and previewPDF() uses the VibeFox JS PDF viewer instead of the browser viewer.
Server-side data
For data that does not fit into the browser set rowModel: 'server' (sorting, filtering and grouping on your server; groups load when expanded) or rowModel: 'infinite' (flat rows, the row count may be unknown) and give a datasource. The grid asks for blocks of rows as the user scrolls.
VibeFoxJSGrid.createGrid('#app', {
rowModel: 'server',
rowId: 'id',
columns: ['id', 'name', { field: 'amount', type: 'number', aggregate: 'sum' }],
datasource: {
async getRows(p) {
const res = await fetch('/api/orders', { method: 'POST', signal: p.signal, body: JSON.stringify({
start: p.startRow, end: p.endRow, sort: p.sort, filter: p.filter, filterModel: p.filterModel,
search: p.quickFilter, groupBy: p.groupBy, groupKeys: p.groupKeys,
}) });
return res.json(); // { rows: [...], rowCount: 12345, aggregates: { amount: 99 } }
},
},
serverSide: { blockSize: 100, maxBlocks: 50 },
});
getRows(params) receives startRow, endRow, sort, filter (column filters by field), filterModel, quickFilter (the query syntax is left to the server), groupBy, groupKeys (values of the expanded parent groups; fewer keys than groupBy = return the group rows of the next level), parentId (server tree data), signal (aborted when the block is no longer needed) and success / fail callbacks. Answer with a promise or a value: { rows, rowCount } (or lastRow), optional aggregates for the totals row, or a plain array. Without a row count the grid grows block by block; a short block is the end. Group rows carry the group field, an optional childCount and aggregate values.
Optional datasource methods: getValues(field, params) (all values of a column for the value-list filter), exportRows(params) (every row of the query in one answer, for export and getAllRows(); otherwise the grid pages through getRows) and getPivot(params) (server pivot).
Block cache (serverSide): blockSize (100), maxBlocks (50), maxConcurrent (2), loadDebounce (30 ms), retries (1), retryDelay (500 ms), groupsExpanded (false), hasChildren (tree data). Pagination works with both models (one block per page); tree: true works with rowModel: 'server'. Placeholder rows are shown while loading, failed blocks show an error row with a Retry button.
Methods: refresh() (request the shown blocks again; { purge: true } drops the cache), setDatasource(ds), retryLoad(), getLoadState(). Events: rowsLoad, rowsError, loadingChange. "Select all" selects every row of the query, also rows that are not loaded: getSelection() then has all: true and except. Unsaved edits survive reloads when rowId is set.
Large data
Virtual scrolling
Only the visible rows and columns are in the DOM. overscan (default 6 rows) and columnOverscan (default 2 columns) render a few more around the visible window; columnVirtualization: false renders every column. Use scrollToRow(rowIdOrIndex) to bring a row into view.
One million rows and more
largeData: true moves sorting, filtering, quick search, grouping and totals of large client data (from 50 000 rows on) into a Web Worker. These operations become asynchronous: the last result stays on screen with a progress box and a Cancel button, and the page stays responsive.
const grid = VibeFoxJSGrid.createGrid('#app', { data: millionRows, rowId: 'id', largeData: { minRows: 50000 } });
grid.setSort([{ field: 'amount', dir: 'desc' }]);
await grid.whenReady(); // resolves when the operation is done
console.log(grid.getOperationState()); // { busy, kind, phase, percent, mode, rows, active }
Options: minRows (50 000), worker (true; false = the same engine in the main thread), progress, progressDelay (200 ms), chunk (25 000 rows per step). Methods: whenReady(), cancelOperation(), getOperationState(). Events: operationStart, operationProgress, operationEnd. The worker is created from a Blob URL; when the page forbids that (Content Security Policy without worker-src blob:) the engine runs in the main thread.
Natural-language queries
The grid turns a question into filters, sorting, grouping, a pivot or highlighting. Built-in rules understand English and Russian (column names by header and field, values of text columns, numbers with units such as 10k, comparisons, ranges, date periods, "top 10", "group by", "pivot by", "highlight … in green", "clear filters"); they need no network and no model.
const result = await grid.ask('orders from Berlin or Paris over 1000, newest first');
result.explanation; // texts of the applied commands
grid.undoQuery(); // or Ctrl+Z
const preview = await grid.ask('top 10 by amount', { preview: true });
preview.commands; // not applied yet
preview.apply();
Option ask: true or { input, preview, adapter, synonyms, locale, now, placeholder }; input: true shows a query bar above the grid (with preview, the commands are shown as chips with Apply / Cancel). synonyms adds your own words for columns: { manager: ['seller', 'rep'] }. The methods work without the option: ask(text, options), interpretQuery(text) (commands only), applyQueryCommands(commands), undoQuery(). Events: queryApply, queryPreview, queryUndo, askFallback.
Your own language model
The grid never calls a model or a service itself. To use one, give an adapter: resolve(text, context) sends the question to your model and returns commands in the format of GRID_QUERY_SCHEMA (a JSON Schema). The answer is checked with validateGridCommands; if it is invalid or the adapter fails, the built-in rules are used and askFallback is emitted.
ask: { input: true, adapter: {
async resolve(text, context) {
// context: { text, locale, today, columns: [{ field, header, type, values }], state, schema }
const res = await fetch('/api/my-llm', { method: 'POST', body: JSON.stringify({ text, context }) });
return res.json(); // [{ type: 'filter', rules: [{ field: 'city', op: 'equals', value: 'Berlin' }] }, ...]
},
} }
Command types: filter (rules, join), sort, group, pivot, format (a conditional formatting rule), quickFilter, clear.
Theming and styling
Themes
Every VibeFox JS component has the themes light (default), dark and high-contrast built into its CSS file. The optional vibefox-js-themes.css adds the theme pack: high-contrast-light, paper, paper-dark, glass, glass-dark, classic, classic-dark, ocean, ocean-dark, forest, forest-dark, sunset, sunset-dark, graphite, graphite-dark. The same file works for every VibeFox JS library.
VibeFoxJSGrid.setTheme('dark'); // the whole page
VibeFoxJSGrid.setTheme('ocean', '#sidebar'); // every component inside a container
grid.setTheme('glass'); // one component (also: the theme option)
grid.setTheme(null); // follow the page / container again
A component without its own theme follows the nearest container with a theme, then the page. After setTheme(name, container) the theme variables are set on the container itself too, so your CSS of the container can use them (#sidebar { background: var(--vfjs-bg); }). Your own theme: registerTheme(name, vars) with the theme variables (bg, fg, border, accent, accent-fg, muted, surface, radius, font, shadow, palette-0 … palette-9 and any other token); it applies at once to every component that uses it. getTheme() returns the page theme, themes lists the registered ones; the event themeChange reports a switch.
VibeFoxJSGrid.registerTheme('brand', { accent: '#e11d48', 'accent-fg': '#ffffff', radius: '10px' });
grid.setTheme('brand');
CSS variables
Every color, size, spacing, font, radius, shadow and duration of VibeFox JS Grid is a CSS variable, so any setting is changed in one place. There are three levels:
- theme variables shared by all VibeFox JS components:
--vfjs-bg,--vfjs-fg,--vfjs-border,--vfjs-accent,--vfjs-accent-fg,--vfjs-muted,--vfjs-surface,--vfjs-radius,--vfjs-font,--vfjs-shadow,--vfjs-palette-0…--vfjs-palette-9; - design tokens: spacing
--vfjs-space-1…--vfjs-space-8, font sizes--vfjs-font-size,--vfjs-font-size-smand others, radii--vfjs-radius-sm…, status colors--vfjs-danger,--vfjs-success,--vfjs-warning,--vfjs-info, the scale--vfjs-size-unit, durations--vfjs-motion-duration, the focus ring--vfjs-focus-ring-colorand--vfjs-focus-ring-width; - variables of the library,
--vfjs-grid-*, which default to the tokens above.
/* all VibeFox JS components of the page */
.vfjs { --vfjs-accent: #0f766e; --vfjs-radius: 4px; }
/* only this grid */
#orders {
--vfjs-grid-row-height: 36px;
--vfjs-grid-header-bg: #eef2ff;
--vfjs-grid-row-selected-bg: #dbeafe;
}
Main groups of the grid variables: frame (--vfjs-grid-bg, --vfjs-grid-fg, --vfjs-grid-font, --vfjs-grid-font-size, --vfjs-grid-radius, --vfjs-grid-border), geometry (--vfjs-grid-row-height, --vfjs-grid-header-height, --vfjs-grid-row-gap, --vfjs-grid-cell-padding-x, --vfjs-grid-column-width), lines (--vfjs-grid-line-color, --vfjs-grid-hline-color, --vfjs-grid-vline-width), header (--vfjs-grid-header-bg, --vfjs-grid-header-fg, --vfjs-grid-header-font-weight, --vfjs-grid-header-text-transform), rows (--vfjs-grid-row-bg, --vfjs-grid-row-alt-bg, --vfjs-grid-row-hover-bg, --vfjs-grid-row-selected-bg), cells (--vfjs-grid-range-bg, --vfjs-grid-active-outline, --vfjs-grid-negative-fg, --vfjs-grid-dirty-color), groups and totals (--vfjs-grid-group-bg, --vfjs-grid-footer-bg), popups (--vfjs-grid-pop-bg, --vfjs-grid-menu-hover-bg), scrollbar (--vfjs-grid-scrollbar-size, --vfjs-grid-scrollbar-thumb), conditional formatting (--vfjs-grid-cf-*), sparklines (--vfjs-grid-spark-*).
From JavaScript: the option styleVars sets variables on the grid element ({ 'row-height': '36px' } = --vfjs-grid-row-height; full names work too), className adds your own classes.
Where to set them: on :root, on any container of your page (#checkout { --vfjs-accent: #0f766e; }), on the element of the component, or in a theme (registerTheme). The closest value wins; a component with its own theme (the option theme or component.setTheme(name)) keeps the theme variables of that theme even inside a container that sets them. A container inside another component (a form inside a dialog or a card) passes the variables of the library to the components in it as well. Only the shared design tokens (--vfjs-space, --vfjs-danger, --vfjs-selected-bg …) do not pass there: set them on a container outside the outer component or on the nested components themselves (#form .vfjs { … }). Popups, menus and dialogs placed in <body> take the values set on the page (:root), not those of the container of their component.
Default values: the theme variables are registered with @property (their initial value is the light theme), so they have a value on every element of the page. The variables of the library (--vfjs-grid-*) keep their defaults inside the stylesheet, at the place where they are used, so a variable that you did not set has no value on your elements:
- in your own CSS that uses a variable of the library, give it a fallback as the library does:
var(--vfjs-grid-bg, var(--vfjs-bg)), or use a theme variable directly; - from JavaScript, read the current value with
cssVar(element, '--vfjs-grid-row-height')(exported by the library; it also returns the default value the component computes);getComputedStyle(element).getPropertyValue()can return an empty string for a variable of the library that nobody set.
/* your own element in the colors of the component */
.my-summary { background: var(--vfjs-grid-bg, var(--vfjs-bg)); color: var(--vfjs-fg); }
const el = document.querySelector('#orders');
console.log(VibeFoxJSGrid.cssVar(el, '--vfjs-grid-row-height')); // the value in use (also a default)
console.log(getComputedStyle(el).getPropertyValue('--vfjs-grid-row-height')); // can be '' unless you set it
If the CSS file of the library comes from another origin without CORS (a <link> without the crossorigin attribute), the browser does not let scripts read the stylesheet, and cssVar() returns an empty string for a variable without a value on the root of the component. From your own origin, or with that attribute, it works.
--vfjs-grid-fx-ref-color has no value of its own: the library sets it on each formula reference, from --vfjs-grid-fx-ref-0 … --vfjs-grid-fx-ref-7; change those. --vfjs-grid-ehl-fg and --vfjs-grid-span-fg default to inherit (the color of the text around them), and cssVar() returns inherit.
The stylesheets are written with native CSS nesting; nothing changes for including them, and your own CSS can be written in any form.
Ready-made styles
The option style (the prop variant in the framework wrappers) picks a ready-made table look; every style works with every theme and density.
| Style | Look |
|---|---|
'default' | Light row lines, zebra stripes. |
'compact' | Smaller rows and font. |
'zebra' | Clear stripes, no row lines. |
'grid' | Every line, no stripes. |
'minimal' | No frame, no vertical lines, muted uppercase header. |
'cards' | Each row is a card with a gap and a shadow. |
'finance' | Monospaced digits, negative numbers in the "down" color, right-aligned number headers. |
'report' | Print-like: no fills, a strong rule under the header, a double rule above the totals, serif font. |
'spreadsheet' | Small rows, every line, centered headers, square corners. |
grid.setStyle('finance'); // or the option style: 'finance'
grid.setStyle('cards', { 'row-gap': '8px' }); // with variables
grid.getStyle(); // 'cards'
GRID_STYLES lists the names; setStyle emits styleChange. Any other name uses your own CSS for the class vfjs-grid-style-<name>.
Density and size
Set data-vfjs-density="compact", "normal" or "comfortable" on the page or on any container: heights and paddings of every VibeFox JS component inside follow. --vfjs-size-unit (default 1px) scales all sizes of a component at once, for example #orders { --vfjs-size-unit: 1.25px; }. Sizes you give as numbers in options are pixels and are not scaled.
Default height: when the element of the component has no height of its own, it gets the class vfjs-auto-height and a default height from the variable --vfjs-grid-min-height (400 px × --vfjs-size-unit). An element with a height of its own (height, only a min-height, a flex item or a CSS Grid item, height: 100% of a parent with a height, absolute insets) gets the class vfjs-fit and is filled exactly, also when it is smaller; the content never makes it taller. With the variable at 0 (class vfjs-content-height) the grid is as high as all its rows, without scrolling of its own.
Your own CSS
All library rules are inside the cascade layer @layer vfjs, so your own CSS always wins without !important. The class names of VibeFox JS Grid start with vfjs-grid- (state classes too, for example vfjs-grid-is-selected), so other CSS frameworks on the page do not restyle it.
.vfjs-grid-row.vfjs-grid-is-selected { font-weight: 600; }
.vfjs-grid-cell.vfjs-grid-is-neg { color: #b91c1c; }
The library ships no font files. It uses the system font stacks of the tokens --vfjs-font, --vfjs-font-mono and --vfjs-font-serif; set them to your own fonts if you want. Animations follow prefers-reduced-motion, and colors follow forced-colors mode (Windows high contrast).
Localization and RTL
Languages
VibeFox JS Grid comes with 14 interface languages. English (en) is built into the library file; each of the others is a language file of its own (dist/locales/vibefox-js-grid.<lang>.js in the package), and a page loads only the ones it uses: Russian (ru), Spanish (es), German (de), French (fr), Italian (it), Portuguese (Brazilian) (pt), Ukrainian (uk), Turkish (tr), Chinese (Simplified) (zh), Japanese (ja), Korean (ko), Hindi (hi) and Arabic (ar). The locale option sets the language of one component; setLocale(lang) sets the default language of the page, which every component without its own locale follows (it re-renders on a change).
VibeFoxJSGrid.setLocale('ru'); // page default
const grid = VibeFoxJSGrid.createGrid('#app', { data: rows, locale: 'en' }); // this grid only
grid.setOptions({ locale: 'de' });
The example above needs the files of the languages it uses. With script tags, load a language file after the library. The order matters: loaded first, the file adds no language and writes a warning to the console.
<link rel="stylesheet" href="vibefox-js-grid.css">
<script src="vibefox-js-grid.global.min.js"></script>
<script src="locales/vibefox-js-grid.ru.js"></script>
With npm or a bundler, import the language after the library. Without npm, an ES module page imports ./locales/vibefox-js-grid.ru.esm.js, which registers the language in vibefox-js-grid.esm.js.
import { createGrid } from '@vibefox/js-grid';
import '@vibefox/js-grid/locales/ru';
The .esm.js language file does not fit the minified build @vibefox/js-grid/min (it would load a second copy of the library). There, use the .json file:
import { createGrid, addLocale } from '@vibefox/js-grid/min';
import ru from '@vibefox/js-grid/locales/ru.json';
addLocale('ru', ru);
Without its file, locale: 'ru' shows English and writes one warning to the console.
Language codes: uk, ko, zh and pt are the real codes; ua and kr also work, as aliases of uk and ko. For each string the library tries the exact code, then the alias, the base language (pt-BR → pt, zh-CN → zh), English, and finally the key itself. normalizeLocale(code) returns the real code of an alias.
A language does not set the direction: with locale: 'ar', also set rtl: true or dir="rtl" on the container. The built-in rules of natural-language queries understand English and Russian whatever language files are loaded.
Adding a language
addLocale(lang, dictionary) adds strings to a language (and creates it): a language of your own, or your own wording over a language file. A missing key follows the chain above, so a partial dictionary works; addLocale('ua', …) fills uk. Add the dictionary before the components that use it are created, or switch the locale afterwards.
VibeFoxJSGrid.addLocale('de', {
noData: 'Keine Daten',
'grid.kb.title': 'Tastenkürzel',
});
The keys of VibeFox JS Grid start with grid. (about 460 keys: menus, dialogs, filters, the status bar, the pager, screen reader texts, keyboard help, conditional formatting, pivot); a few common words are shared keys without a prefix: ok, cancel, close, search, loading, noData, export, today, apply, clear, delete, edit, save. The language files list every key (locales/vibefox-js-grid.ru.json); the English texts are in the readable file vibefox-js-grid.esm.js. Placeholders in braces, such as {count}, are filled in by the library. t(key, params) translates a key in the page locale, grid.t(key) in the grid's locale; getLocale() returns the page locale, onLocaleChange(fn) reports changes.
Plural forms: a text with a number has the keys <key>.zero, .one, .two, .few, .many and .other (the categories of Intl.PluralRules); .other is the fallback, so your dictionary can give only that form. {count} and {n} are filled in. tPlural(key, count, params, lang) picks the form; the method grid.tPlural(key, count, params) does it in the locale of the component.
VibeFoxJSGrid.addLocale('de', {
'grid.rows.one': '{n} Zeile',
'grid.rows.other': '{n} Zeilen',
});
VibeFoxJSGrid.tPlural('grid.rows', 5, {}, 'de'); // '5 Zeilen'
Numbers are formatted with a no-break space between digit groups; for the grid the decimal separator, the CSV number form and the formula separators follow the grid locale.
Right-to-left
The option rtl: true lays the component out right-to-left (dir="rtl" on its element); rtl: false forces left-to-right; without it the component follows the page or its container (<html dir="rtl">). The arrow keys follow the reading order. isRtl(element) tells the direction of an element.
In VibeFox JS Grid the columns start on the right and left-pinned columns are pinned at the start of the row (the right side); PDF, printing and Excel export of a right-to-left grid follow the screen (see Export, import and printing → Right-to-left exports).
Accessibility
VibeFox JS Grid follows the WAI-ARIA grid pattern: the grid is one tab stop, the arrow keys move the active cell, and screen readers get roles, names, states and announcements. Focus is visible (the focus ring is the CSS variables --vfjs-focus-ring-color, --vfjs-focus-ring-width, --vfjs-focus-ring-offset, --vfjs-focus-ring-style); dialogs keep the focus inside and give it back when they close. The high-contrast and high-contrast-light themes, forced-colors mode and prefers-reduced-motion are supported.
Keyboard
Ctrl+/ or F1 opens a dialog with all shortcuts (also the last item of the context menu, or showKeyboardHelp()). On macOS, Cmd works where Ctrl is listed.
| Keys | Action |
|---|---|
| ↑ ↓ ← → | Move between cells. |
| Home, End | First / last cell of the row. |
| Ctrl+Home, Ctrl+End | First / last row. |
| PageUp, PageDown | One page up / down. |
| Enter, F2 | Edit the cell. |
| Esc | Cancel editing, close a menu. |
| Tab, Shift+Tab | Next / previous cell while editing. |
| Space | Select the row (row selection). |
| Shift+arrows | Extend the cell range. |
| Ctrl+A | Select all. |
| Ctrl+C, Ctrl+V | Copy / paste. |
| Delete | Clear the cells. |
| Ctrl+Z, Ctrl+Y | Undo / redo. |
| Ctrl+D, Ctrl+R | Fill down / right. |
| ↑ (on the first row) | To the column headers. |
| ↑ ↓ (in the header) | To the column group headers and back; Enter opens / closes a group. |
| Enter, Shift+Enter (header) | Sort / add to the sort. |
| Alt+↓ (header) | Open the filter. |
| G (header) | Group the rows by the column / remove it from the grouping. |
| Enter, →, ← (group row) | Expand / collapse. |
| →, ← (tree, first column) | Expand / collapse. |
| →, ←, Alt+Enter (master row) | Show / hide the details. |
| Enter, Esc (detail row) | Into the details / back to the grid. |
| Alt+↑, Alt+↓ | Move the rows up / down (row drag on). |
| Alt+→, Alt+← (tree) | Into the row above / out of the parent. |
| Space, Alt+↑ ↓, Alt+← → (columns panel) | Show / hide, move, pin to the left / right. |
| ← →, Alt+← →, Delete (grouping panel) | Go to a level, reorder, remove. |
| R, C, V, F (pivot panel) | To rows / columns / values, filter. |
| Alt+↓, Ctrl+Enter (popup editors) | Open the list / calendar; large text: save. |
| =, Tab (formulas) | Start a formula; insert the suggested function. |
| Shift+F10, Menu key | Context menu of the active cell. |
| Ctrl+/, F1 | Keyboard help. |
Screen readers
Roles: grid (treegrid with grouping or tree data), row, columnheader, gridcell; aria-rowcount, aria-colcount, aria-rowindex and aria-colindex give the real positions also with virtual scrolling; aria-sort, aria-selected, aria-expanded, aria-level, aria-readonly and aria-busy give the state; the active cell is aria-activedescendant. The grid announces sorting, filter results, selection, grouping, expanded rows, page changes and load errors through a live region; announce: false turns that off. ariaLabel sets the accessible name (default: "Data grid").
Methods: getActiveCell(), setActiveCell(cell, { focus }), showKeyboardHelp(), hideKeyboardHelp(). The library also exports the helpers it uses itself: announce(message), trapFocus, rovingFocus, setAria, prefersReducedMotion() and others (see API reference).
Using with other VibeFox JS libraries
VibeFox JS Grid works on its own. Every VibeFox JS library is a separate file with its own copy of the shared core, and several libraries on one page work together without conflicts: one global variable per library (VibeFoxJSGrid, VibeFoxJSCharts, …), class names with the library prefix, one page theme, the same events.
Connecting components with link()
link(source, event, target, method, transform) calls a method of one component whenever another emits an event; it returns a function that removes the link. connect(source, event, handler) subscribes and returns an unsubscribe function. bus is a page-wide event channel shared by all VibeFox JS libraries on the page.
// a grid drives a chart of VibeFox JS Charts (both files loaded on the page)
const unlink = VibeFoxJSGrid.link(grid, 'selectionChange', chart, 'setOptions', (e) => ({
categories: e.rows.map((r) => r.name),
series: [{ name: 'Salary', data: e.rows.map((r) => r.salary) }],
}));
VibeFoxJSGrid.bus.emit('orders:refresh', { at: Date.now() }); // any library can listen: VibeFoxJSCharts.bus.on('orders:refresh', fn)
What uses another library when it is on the page
- Charts of cell ranges: work on their own with the grid's SVG chart; if VibeFox JS Charts is also on the page, they are drawn with VibeFox JS Charts.
- PDF export and printing: work on their own; if VibeFox JS PDF is also on the page,
toPdfDocument(),addToPdfDocument()and the VibeFox JS PDF viewer inpreviewPDF()are available. - Row drag between grids, master / detail grids: within VibeFox JS Grid.
AI tools
The library describes its main actions as tools for function calling with a language model. It never calls a model or a service itself: you send the descriptions to your model and run the calls it asks for.
| Tool | What it does |
|---|---|
grid_describe | Columns, row counts, current sort, filters and grouping. |
grid_get_rows | Shown rows (offset, limit up to 500, fields). |
grid_query | Applies query commands (filter, sort, group, pivot, format) as one undo step. |
grid_undo_query | Undoes the last query. |
const { describeTools, callTool, createToolKit } = VibeFoxJSGrid;
const tools = describeTools(grid, { format: 'openai' }); // 'plain' / 'anthropic', 'openai', 'webmcp'
const result = await callTool(grid, 'grid_get_rows', { limit: 20 }); // { ok: true, result } or { ok: false, error }
const kit = createToolKit({ orders: grid }); // tool names get the prefix 'orders_'
const answer = await kit.ask('Show only unpaid orders', {
format: 'anthropic',
model: async (request) => (await fetch('/api/llm', { method: 'POST', body: JSON.stringify(request.body) })).json(),
});
callTool checks the arguments against the tool schema before it runs and never throws for bad input. createToolKit(components, { webmcp, readOnly }) joins the tools of several components (also of other VibeFox JS libraries) under unique names; kit.ask(prompt, { model, format, system, maxSteps, signal, onToolCall }) runs the loop "model → tool calls → results" with your model function; kit.registerWebMCP() registers the tools in the browser's navigator.modelContext where available. registerTools(target, provider) adds your own tools; validateSchema(value, schema) is the schema check.
API reference
Exports
Library: createGrid, VibeFoxJSGrid, GRID_STYLES, CF_ICON_SETS, PIVOT_AGGREGATES, GRID_QUERY_SCHEMA, validateGridCommands, FormulaEngine, createFormulaEngine, registerFormulaFunction, unregisterFormulaFunction, FormulaError, FormulaSyntaxError, parseFormula, shiftFormula, formulaToR1C1, formulaToA1, localizeFormula, delocalizeFormula, FORMULA_FUNCTIONS.
Shared core (the same in every VibeFox JS library): setTheme, getTheme, registerTheme, themes, tokens, componentTokens, densities, cssVar, cssColor, cssLength, observeTokens, setLocale, getLocale, addLocale, normalizeLocale, t, tPlural, withLocale, onLocaleChange, link, connect, bus, Emitter, VibeFoxJSComponent, factory, toCSV, downloadFile, downloadCanvasPNG, createXlsx, readXlsx, XLSX_MIME, createZip, readZip, crc32, createVectorContext, VectorContext, vectorToSVG, vectorToPDF, printSVG, createVectorImage, loadVectorImage, SVG_MIME, PDF_MIME, PDF_PAGE_SIZES, describeTools, callTool, createToolKit, registerTools, validateSchema, announce, trapFocus, rovingFocus, getFocusable, focusFirst, saveFocus, setAria, ensureId, addAriaRef, removeAriaRef, isRtl, mirrorArrow, prefersReducedMotion, prefersHighContrast, motionDuration, onPreferenceChange, injectStyles, ensureBaseStyles, formatNumber, formatDate, escapeHtml, createEl, deepMerge, isPlainObject, getPath, setPath, uid, clamp, debounce, throttle, VERSION.
Options
Also every VibeFox JS component accepts theme, locale, rtl and on (see Core concepts).
| Option | Type | Default | Description |
|---|---|---|---|
data | object[] | [] | Rows. |
columns | array or null | null | Columns and column groups; null = from the data. |
height | number, string or null | null | Height of the rows area in px or any CSS size; null = the grid fills the height of its element (without one, the rows area is --vfjs-grid-min-height, 400 px). |
rowHeight | number, function or null | null | Row height; null = --vfjs-grid-row-height. |
headerHeight | number or null | null | Header height; null = --vfjs-grid-header-height. |
overscan | number | 6 | Extra rows rendered around the visible ones. |
sortable | boolean | true | Sorting by header click. |
multiSort | boolean | true | Shift+click adds to the sort. |
filterable | boolean | true | Header filter buttons. |
editable | boolean | false | Cells are editable. |
resizable | boolean | true | Column resizing. |
reorderable | boolean | true | Column drag and drop. |
selection | object | { mode: 'row', multi: true, checkbox: false, cellRanges: true } | Selection mode. |
groupBy | string[] | [] | Grouping fields. |
groupDefaultExpanded | boolean | true | Groups start expanded. |
tree | boolean | false | Tree data. |
childrenField | string | 'children' | Field with the child rows. |
treeDefaultExpanded | boolean | true | Tree nodes start expanded. |
pagination | false or { pageSize, pageSizes } | false | Pages instead of endless scrolling. |
footer | boolean | false | Totals row. |
striped | boolean | true | Zebra stripes. |
hover | boolean | true | Row hover highlight. |
statusBar | boolean | false | Status bar. |
quickFilter | string | '' | Initial quick search text. |
smartQuery | boolean | true | Query syntax in the quick search. |
contextMenu | boolean or (items, info) => items | true | Context menu; a function changes the items. |
changeTracking | boolean | true | Track unsaved edits. |
rowId | string, function or null | null | Row identity. |
emptyText | string or null | null | Text without rows (default: localized "No data"). |
columnVirtualization | boolean | true | Render only the columns near the viewport. |
columnOverscan | number | 2 | Extra columns on each side. |
undo | boolean | true | Undo / redo. |
undoLimit | number | 100 | Maximum undo steps. |
rowModel | 'client' | 'server' | 'infinite' | 'client' | Where rows come from. |
datasource | object or null | null | Rows of the server / infinite model. |
serverSide | object | see Server-side data | Block cache. |
ariaLabel | string or null | null | Accessible name. |
announce | boolean | true | Screen reader announcements. |
style | string or null | null | Ready-made table style. |
className | string or string[] | '' | Own classes on the grid element. |
styleVars | object or null | null | CSS variables on the grid element. |
wrapText | boolean | false | Wrap cell text. |
autoRowHeight | boolean | false | Rows grow to fit their cells. |
wrapHeaderText | boolean | false | Wrap header text. |
rowDrag | boolean or object | false | Row drag and drop. |
pinnedTopRows | array, function or null | null | Rows pinned under the header. |
pinnedBottomRows | array, function or null | null | Rows pinned at the bottom. |
newRow | boolean or object | false | New-row input. |
masterDetail | boolean or object | false | Master / detail rows. |
fillHandle | boolean or object | true | Fill handle (cell selection mode). |
filterMenu | 'excel' | 'simple' | 'excel' | Header filter menu. |
filterBuilder | boolean or { maxDepth } | true | Filter builder. |
sideBar | boolean or object | false | Columns tool panel. |
groupPanel | boolean or { hint } | false | Grouping panel. |
pivot | boolean or object | false | Pivot mode. |
formulas | boolean or object | false | Formulas in cells. |
rangeChart | boolean or object | true | Charts of cell ranges. |
conditionalFormats | array | [] | Conditional formatting rules. |
conditionalFormatMenu | boolean | true | Context menu item for the rules dialog. |
largeData | boolean or object | false | Web Worker mode for 1 million+ rows. |
ask | boolean or object | false | Natural-language queries. |
Events
| Event | Payload | Description |
|---|---|---|
ready | { component } | Created and rendered. |
dataChange | { data } | Rows replaced or changed. |
optionsChange | { options, patch } | setOptions applied a patch. |
themeChange | { theme } | Theme switched. |
destroy | { component } | Being destroyed. |
rowClick, rowDblClick | { row, id, index, event } | Row clicked. |
cellClick, cellDblClick | { row, id, field, value, event } | Cell clicked. |
headerClick | { field, event } | Header clicked. |
contextMenu | { row, field, col, event } | Context menu opened. |
sortChange | { sort } | Sort changed. |
filterChange | { filters, quickFilter, filterModel } | Filters changed. |
groupChange | { groupBy } | Grouping changed. |
groupToggle | { key, field, value, expanded } | Group expanded / collapsed. |
treeToggle | { id, row, expanded } | Tree node expanded / collapsed. |
selectionChange | { ids, rows, range, all?, except? } | Selection changed. |
editStart | { row, id, field, value } | Editor opened. |
editEnd | { row, id, field, oldValue, value, cancelled } | Editor closed. |
cellChange | { row, id, field, oldValue, value } | A cell value was written. |
changesChange | { count, changes } | The list of unsaved changes changed. |
historyChange | { action, source, cells, canUndo, canRedo, undoSize, redoSize } | Undo history changed. |
copy | { text, rows } | Selection copied. |
paste | { updates, rows } | Text pasted. |
fillStart | { range, preventDefault } | Fill handle drag starts (cancelable). |
fill | { source, target, direction, mode, keyboard, cells, preventDefault } | Cells are about to be filled (cancelable). |
fillEnd | { source, target, direction, mode, keyboard, changed, skipped, cancelled } | Fill ended. |
columnResize | { field, width, group? } | Column resized. |
columnReorder | { field, target, order, group?, fields? } | Column moved. |
columnPin | { field, pin } | Column pinned. |
columnHide | { field, hidden } | Column hidden / shown. |
columnGroupToggle | { groupId, expanded } | Column group opened / closed. |
columnGroupClick | { groupId, event } | Column group header clicked. |
toolPanelChange | { open, panel } | Tool panel opened / closed. |
pageChange | { page, pageCount } | Page changed. |
styleChange | { style, className } | Table style switched. |
rowDragStart | { rows, ids, event, preventDefault } | Row drag starts (cancelable). |
rowDrag | GridRowDragEvent | Running drag, its drop and cancel (link to receiveRowDrag). |
rowDrop | GridRowDropEvent | Rows dropped on this grid (cancelable). |
rowDragEnd | { rows, ids, dropped, target, copy, cancelled, event } | Drag ended. |
rowAdd | { rows, index, parentId, source, preventDefault } | Rows are added (cancelable). |
rowRemove | { rows, ids, source, preventDefault } | Rows are removed (cancelable). |
detailToggle | { id, row, expanded } | Detail row shown / hidden. |
detailGridReady | { id, row, grid } | Nested grid created. |
pivotChange | { pivot } | Pivot layout changed. |
pivotCompute | { ms, rows, columns, source } | Pivot computed. |
formulaChange | { field, formula, oldFormula } | Computed column formula changed. |
conditionalFormatChange | { rules } | Formatting rules changed. |
rangeChartCreate | { chart, engine } | Range chart created. |
rangeChartDestroy | { chart } | Range chart closed. |
import | { format, sheet, rows, columns, warnings, ms } | .xlsx file imported. |
importProgress | { format, phase, rows, total, percent } | Import progress. |
export | { format, filename, pages } | PDF downloaded or print dialog opened. |
rowsLoad | { startRow, endRow, groupKeys, rows, rowCount } | Server block arrived. |
rowsError | { startRow, endRow, groupKeys, error, attempt, retry } | Server block failed. |
loadingChange | { loading, pending } | Loading started / finished. |
operationStart | { kind, what, rows, mode } | Large data operation started. |
operationProgress | { kind, phase, percent } | Large data operation progress. |
operationEnd | { kind, ms, cancelled, mode } | Large data operation ended. |
queryApply | { text, commands } | Query applied. |
queryPreview | { text, commands, explanation, source } | Query previewed. |
queryUndo | {} | Query undone. |
askFallback | { text, error } | The adapter failed; rules used. |
Methods
Methods that change the grid return the grid, so calls can be chained.
| Method | Returns | Description |
|---|---|---|
setData(rows) / getData() | this / rows | Replace / read the rows. |
setOptions(patch), setOption(path, value), getOption(path) | this / value | Options. |
getState() / setState(state) | state / this | Snapshot of the user state. |
setTheme(name) | this | Own theme; null follows the page. |
on, once, off, emit | this | Events. |
use(plugin, options) | this | Install a plugin. |
t(key, params) | string | Translate in the grid's locale. |
tPlural(key, count, params) | string | Translate a key with plural forms in the grid's locale. |
destroy() | — | Remove the grid. |
refresh(options) | this | Recompute and repaint; server: request again. |
setColumns(columns) / getColumns() | this / columns | Column definitions. |
setColumnWidth(field, width) | this | Column width. |
autoSizeColumns(field) | this | Fit widths to the content. |
pinColumn(field, side) | this | Pin a column. |
hideColumn(field, hidden), showColumn(field), hideColumns(fields, hidden) | this | Visibility. |
moveColumn(field, targetField, after) | this | Move a column. |
getColumnGroups() | array | Column groups. |
setColumnGroupExpanded(groupId, expanded), toggleColumnGroup(groupId) | this | Open / close a group. |
moveColumnGroup(groupId, targetField, after) | this | Move a column group. |
setRowHeight(rowId, height), getRowHeight(rowId), resetRowHeights(options) | this / number | Row heights. |
setSort(sort), getSort(), toggleSort(field, additive) | this / sort | Sorting. |
setFilter(field, filter), getFilters(), clearFilters() | this / filters | Column filters. |
setFilterModel(model), getFilterModel() | this / model | AND / OR filter model. |
showFilterBuilder(anchor), hideFilterBuilder() | this | Filter builder dialog. |
setQuickFilter(text), getQuickFilter() | this / string | Quick search. |
setGroupBy(fields), getGroupBy() | this / fields | Grouping. |
expandAll(), collapseAll() | this | Groups and tree nodes. |
getSelection(), getSelectedRows() | selection / rows | Selection. |
setSelection(ids), selectAll(), clearSelection() | this | Change the selection. |
getCellRange(), setCellRange(range) | range / this | Cell range (cell mode). |
copySelection(withHeaders) | this | Copy as TSV. |
beginEdit(rowIdOrIndex, field) | boolean | Open an editor. |
endEdit(commit) | this | Close the editor. |
setCellValue(rowId, field, value), getCellValue(rowId, field) | this / value | Write / read a cell. |
getChanges(), revertChanges(), acceptChanges() | changes / this | Change tracking. |
undo(), redo(), canUndo(), canRedo(), clearHistory() | this / boolean | Undo / redo. |
batchEdit(fn, source) | this | Several writes as one undo step. |
fillSelection(direction, options) | this | Fill the cell range. |
setPage(page), getPage(), getPageCount() | this / number | Pagination. |
getViewData() | rows | Filtered and sorted rows. |
getAllRows(options) | Promise of rows | Every row of the query. |
getColumnStats(field) | stats | Column statistics. |
exportCSV(filename, options), getCSV(options) | this / Promise of string | CSV. |
exportJSON(filename) | this | JSON download. |
getXlsxSheet(options), getXlsx(options), exportXlsx(filename, options) | sheet / Promise of bytes | Excel export. |
importXlsx(file, options), getXlsxSheets(file) | Promise | Excel import. |
setCellStyle(rowId, field, style), getCellStyle(rowId, field), clearCellStyles() | this / style | Own cell styles. |
getPrintLayout(options), getPDF(options), exportPDF(filename, options), print(options) | layout / Promise | PDF and printing. |
toPdfDocument(options), addToPdfDocument(doc, options), previewPDF(target, options) | Promise | VibeFox JS PDF integration, preview. |
createRangeChart(options), getRangeChartData(options), getRangeCharts(), destroyRangeCharts() | chart / data | Range charts. |
setDatasource(ds), retryLoad(), getLoadState() | this / state | Server model. |
showKeyboardHelp(), hideKeyboardHelp() | this | Keyboard help dialog. |
getActiveCell(), setActiveCell(cell, options) | cell / this | Active cell. |
scrollToRow(rowIdOrIndex) | this | Scroll a row into view. |
receiveRowDrag(event), addRowDropTarget(target, options), removeRowDropTarget(target) | this | Row drag between grids / elements. |
addRows(rows, options), removeRows(ids) | this | Add / remove rows. |
setPinnedRows(side, rows), getPinnedRows(side) | this / rows | Pinned rows. |
getNewRow(), addNewRow(options), resetNewRow() | draft / boolean / this | New-row input. |
expandDetail(rowId), collapseDetail(rowId), toggleDetail(rowId, expanded), isDetailExpanded(rowId), getExpandedDetails(), getDetailGrid(rowId), getDetailElement(rowId) | this / value | Master / detail. |
openToolPanel(options), closeToolPanel(), toggleToolPanel(open), isToolPanelOpen() | this / boolean | Columns tool panel. |
setStyle(name, vars), getStyle() | this / name | Table style. |
setPivot(patch), getPivot(), setPivotMode(on), isPivotMode(), setPivotFilter(field, filter), showPivotFilter(field, anchor), getPivotResult(), getPivotCell(rowId, field) | this / value | Pivot mode. |
setColumnFormula(field, formula), getColumnFormula(field), getCellFormula(rowId, field), evaluateFormula(formula, at), calculate(), recalculate(), registerFunction(name, fn), getFormulaEngine() | this / value | Formulas. |
setConditionalFormats(rules), getConditionalFormats(), addConditionalFormat(rule, index), updateConditionalFormat(id, patch), removeConditionalFormat(id), clearConditionalFormats(), getCellFormat(rowId, field), showConditionalFormats(field), hideConditionalFormats() | this / value | Conditional formatting. |
cancelOperation(), whenReady(), getOperationState() | boolean / Promise / state | Large data mode. |
interpretQuery(text, options), ask(text, options), applyQueryCommands(commands), undoQuery() | Promise / boolean | Natural-language queries. |
The TypeScript declarations (vibefox-js-grid.d.ts) describe every option, payload and return type in detail: GridOptions, GridColumn, GridEvents, GridState, GridDatasource, GridXlsxOptions, GridPdfOptions, GridConditionalFormat, GridPivotOptions and others.
Troubleshooting
No styles
Link vibefox-js-grid.css next to the script. Without it the component works but is unstyled, and the console shows one warning "VibeFox JS stylesheet is not loaded". In a bundler, import @vibefox/js-grid/css. The framework wrappers do not add the CSS for you.
My CSS does not apply, or a page CSS framework changes the component
Your rules win over the library rules without !important because the library CSS is in @layer vfjs. If they still do not apply, check the class names: state classes have the library prefix (vfjs-grid-is-selected, not is-selected). The library never uses generic class names, so page CSS frameworks do not change it.
ES modules do not load from disk
Browsers load <script type="module"> only over http(s). Use a local web server, or use vibefox-js-grid.global.js, which also works from file://.
Content Security Policy
The library does not use eval or inline scripts and loads nothing from the network. It sets inline styles on its elements (sizes and positions), so a policy with style-src must allow them ('unsafe-inline' for style attributes). The large data mode creates its Web Worker from a Blob URL (worker-src blob:); without that permission it falls back to the main thread.
Text in the PDF is not in my font
The library ships no fonts. The PDF uses the standard PDF fonts; text outside them stays selectable but is drawn with a fallback. Pass your own font files with embedFonts (.ttf, .otf or .woff), or embedFonts: true to take the @font-face fonts of the page.
Nothing is shown or the grid has the wrong height
The target element must exist when createGrid runs (a selector that finds nothing throws an error). The grid fills its element: give the element a height (CSS or an inline style), or give the grid a number in height; without either, the rows area is 400 px high. In a flex or grid layout the grid takes the size of its cell, however many rows it has.
Large data is slow
Set rowId, give column definitions instead of letting the grid infer them, avoid HTML renderers that do heavy work per cell, keep columnVirtualization on, and use largeData: true from about 50 000 rows on, or the server-side row model for data that does not fit into the browser.
Edits, selection or expanded rows are lost after setData
Set rowId. Without it the grid gives rows new ids on every setData, and everything that refers to rows by id (selection, unsaved changes, undo history, expanded master rows) cannot find them.
Copy and paste do not work
The browser gives clipboard access only on secure pages (https or localhost) and after a user action.
Limitations
- Server-side and infinite row models: row drag is events only (
managedis always off), the smart query syntax of the quick search is passed to the server as text, andtreeis ignored withrowModel: 'infinite'. - Column spans and row spans do not cross pinned zones, group rows, detail rows or pages; when spans conflict, the first one wins.
- Pinned rows cannot be selected or dragged; their edits have no undo and they are not conditionally formatted.
- Rows cannot be resized by dragging (use
setRowHeight); the editor of a wrapped cell is a one-line input. - A drop of rows between grids cannot be done with the keyboard; undo of a move between grids is in the target grid.
- Pivot mode: compact layout only (one label column), no "show values as" (percent of total, running totals), the result is read-only; pinned rows, master / detail and row drag are off; the quick search and the filter builder do not filter the source rows (use pivot field filters); computed columns are not pivot fields.
- Formulas: no dynamic arrays (spill), function names are English in every locale, the editor is one line (no formula bar), a circular reference gives
#CIRC!; volatile functions and formulas with defined formula names are recomputed after every change. - Range charts with the built-in chart: four types, no axis titles or data labels, pie uses the first series only.
- Excel import: no fonts, borders, vertical alignment, rich text inside a cell, charts, images or comments (they are listed in
warnings); number formats are per column; time-only cells become text; merges across the header are not imported; the right-to-left flag of a sheet is not read. - PDF / print: custom renderers are printed as text, images in cells are not drawn, detail rows are not printed, data bars are solid; sparklines are drawn left to right also in a right-to-left grid (as on the screen).
- Conditional formatting rules apply to whole columns; data bars have no minimum length.
- Natural-language queries understand one question at a time (a new question replaces the filters of the previous one), compare dates as days, and look at up to 2 000 distinct values per text column.
- Large data mode: the quick search tests every cell on its own (a term across two cells does not match); own aggregate functions run in the main thread; the first sort of a text column with a million distinct values takes a few seconds (the page stays responsive); the browser height limit (about 33.5 million px) allows about one million rows of 30 px, so taller data needs pagination.
- Value lists of the filter menu show up to 1 000 values (date tree up to 20 000; server: 5 000).
aria-setsize/aria-posinsetare not set; the keyboard help shows "Ctrl" also on macOS.- Framework wrappers: functions in options are compared by reference; removing a prop does not reset the option to its default; Vue watches object props shallowly.
