Create your first grid
Use Canvas for an interactive browser grid. Use core alone for Node.js, a custom renderer or a headless data workflow. React and Vue wrap the same Canvas renderer; they do not introduce a different data model.
公開パッケージの範囲です。アプリにインストールしたバージョンを選択してください。
技術本文は英語です。ナビゲーションは選択した言語に対応します。
Choose your version
This guide targets version 0.3.0 development preview for all eight packages: core, Canvas, React, Vue, Markdown, MCP, export and charts. APIs remain experimental. Pin the same version across packages. Live data, multi-sort, query snapshots, find/replace and the documented remote-write APIs are included in 0.3.0.
This guide targets npm 0.3.0. The archived npm 0.1.0 channel retains its original API scope; see documentation versions.
Install
Use an ESM application with a bundler. Node.js 22 or later is required for repository builds and checks; browser mounting requires Canvas 2D and ResizeObserver.
npm install @acheron-grid/[email protected] @acheron-grid/[email protected]
For a framework, add only its adapter and supply its peer dependency:
npm install @acheron-grid/[email protected] react react-dom
# Or, for Vue:
npm install @acheron-grid/[email protected] vue
React accepts React 18.3 or 19; Vue requires Vue 3.5 or later within Vue 3. Browser/framework coverage is described in support.
Mount
Give the container explicit dimensions. A zero-height container cannot display a grid.
<div id="grid" style="width:100%;height:480px"></div>
Put this in your browser entry module:
import { LocalDataSource } from '@acheron-grid/core';
import { createGrid } from '@acheron-grid/canvas';
const container = document.querySelector<HTMLElement>('#grid');
if (!container) throw new Error('Missing #grid container.');
const source = new LocalDataSource([
{ id: 'r1', name: 'Ada', score: 42 },
{ id: 'r2', name: 'Lin', score: 57 },
], row => row.id);
const grid = createGrid({
container,
dataSource: source,
columns: [
{ key: 'name', title: 'Name', editable: true },
{ key: 'score', title: 'Score', editable: true,
parse: text => Number(text),
validate: value => typeof value === 'number' && Number.isFinite(value)
? undefined : 'Enter a finite number.' },
],
});
// Programmatic values are typed; parsers convert editor/paste text only.
grid.updateCells([{ rowIndex: 0, columnKey: 'score', value: 43 }]);
grid.undo();
// Call this when your application removes the grid's owning view.
export function dispose() { grid.destroy(); }
The grid shows two records. Double-click a name or press F2 to edit; numeric text is parsed and validated before saving. updateCells() uses typed values and still runs column validation and writable permissions. It does not run parsers or require the editor's editable flag.
Understand the data model
| Concept | Rule |
|---|---|
| Row ID | Unique string or finite number; retain it when the same record changes |
| Column key | Unique field name; independent of its display title |
| Coordinates | Zero-based visible row/column indices; the row-index gutter is not a data column |
| Data source | Synchronous reads; writable sources provide synchronous atomic setters |
| Ownership | The grid owns its DOM/history; your application owns data transport and source lifetime |
LocalDataSource keeps shallow row snapshots. Nested arrays and objects remain application-owned. Use grid commands for tracked writes; direct source writes need an explicit refresh and do not become undo commands.
Next steps
- Integration guide: validation, clipboard, views, refresh, persistence and extensions.
- React or Vue: stable options, runtime props and cleanup.
- Core: headless contracts and 0.3.0 remote/live recipes.
- Canvas: browser editors, media, layout and keyboard behavior.
- Security boundaries: server authorization and trusted host callbacks.
Build a source preview
The website identifies the exact source revision for its preview docs. Check out that revision before using source-only APIs; do not assume the default branch or npm 0.1.0 contains them.
git clone --branch v0.3.0 https://github.com/haodn-dev/acheron-grid.git
cd acheron-grid
npm ci
npm run build
npm run playground
For a consumer project, pack and install all packages you need together so the internal 0.3.0 dependency ranges resolve to the same source artifacts:
# In the built engine checkout:
npm pack --workspace @acheron-grid/core --workspace @acheron-grid/canvas --pack-destination /absolute/path/to/artifacts
# In your application:
npm install /absolute/path/to/artifacts/acheron-grid-core-0.3.0.tgz /absolute/path/to/artifacts/acheron-grid-canvas-0.3.0.tgz
Create the artifacts directory first. Add export/charts/framework tarballs to the same install command when needed. For changes after v0.3.0, record the exact Git revision and use matching source artifacts; do not mix those changes with registry packages.
Troubleshooting
| Symptom | Check |
|---|---|
| Blank grid | Container dimensions, browser console, correct browser entry point |
| Editing is unavailable | Editable column, writable source, current permissions and locks |
| Numeric paste fails | Add a parser and validation for the typed column |
| Edits disappear after a React/Vue update | Keep options identity stable; a new options object intentionally remounts |
| External changes do not appear | Call refreshData() with the correct identity mode |
| API missing from npm | Match docs to your installed version; upgrade to 0.3.0 for its APIs |
変更内容
- r1 — Complete pinned-install browser example and troubleshooting.
- r2 — Complete pinned-install browser example and troubleshooting.
- r3 — Complete pinned-install browser example and troubleshooting.
- r4 — Complete pinned-install browser example and troubleshooting.
- r5 — Complete pinned-install browser example and troubleshooting.
- r6 — Complete pinned-install browser example and troubleshooting.