@fieldia/grid

中文文档
0.36.1发布于 2026/10/28MITTypeScriptESM + CJS近 30 天下载 4073

Fieldia's table of lines on AG Grid: spreadsheet editing with Fieldia's own fields in the cells.

原始使用文档

@fieldia/grid

A Fieldia table of lines as a spreadsheet, on AG Grid Community. Each cell is edited with Fieldia's own field for its type, wired to its line, so every keystroke reaches the form and computed values follow while a cell is being typed.

npm install @fieldia/grid ag-grid-community
import { mountViewer } from '@fieldia/viewer';
import { gridWidgets } from '@fieldia/grid';

mountViewer(host, { page, dataSource, widgets: gridWidgets });

A one2many node opts in with "widget": "grid"; nodes without it keep the plain table, so pages that do not use the grid never load AG Grid. In React pass widgets={gridWidgets}, in Vue :widgets="gridWidgets", in Angular [widgets]="gridWidgets".

{ "type": "field", "id": "f-lines", "field": "line_ids", "widget": "grid",
  "totals": ["qty", "subtotal"], "optionalColumns": { "discount": "show" } }
  • Keys: Enter keeps a cell and moves down, Tab moves across (skipping cells that cannot be edited), Tab or Enter at the end starts a new line, Escape puts a cell back, Space ticks yes/no, Alt+Up/Down moves a line.
  • Sections and notes (lineKinds on the field) run across the row; a note grows as it is typed.
  • Moving lines by a handle, with a sequenceField on the field.
  • Totals under the lines, columns people resize, move and choose (kept in the viewer's preferences store), long tables that scroll inside, and "editMode": "row" to open a whole line at once. A column moves by dragging its header, as in a list: Escape puts it back, a drag out of the grid never hides it, a finger resting a moment on a header lifts its column (a swipe there scrolls the page), and its new place is said to a screen reader.
  • A refused save marks the wrong cells and opens the first one.
  • On a phone (the grid 520px wide or less) its lines are cards, as where the node says "cards": "narrow": each value whole by its column's label, a card's title opening the line in its own form (a section's or a note's, its words), a line added opening there and going again if let go. Where the host gives no dialogs to open a line in, the grid stays a grid; "cards": "never" keeps it one, "always" makes cards at every width.
  • A choice a line's change took out is said under its cell, the row as tall as the words need, and aloud.
  • Most lines ("options": { "max": 12 } on the node), as the plain table keeps them: at its most, Add and a line's copy are hidden (never disabled), and Enter or Tab at the last line's end adds none.
  • Rows pasted from a spreadsheet on a chosen cell (Ctrl+V, ⌘V in Safari too), or in a cell a click opened for typing, go each on its own line from it, as the plain table pastes them: each cell read as its column reads what is typed, a link by its exact name through the source's search; a row whose name reads as no record is not pasted at all; rows past the last line add lines, as many as the node's options.max allows; one note says what went in, the lines added, and what did not, with why. One value pasted in an open cell stays in its box. The readers come in the lines part, asked for the first time a block is pasted.

gridApiOf(element) returns the AG Grid API behind a grid, for an app that needs more than the page describes.

MIT. AG Grid Community is MIT too; AG Grid Enterprise is not used.

版本与发布记录

@fieldia/grid 共发布 48 个版本,首次发布于 2026/10/02;过去 12 个月发布了 48 个版本。

版本发布日期距今
0.36.1latest2026/10/2817 天前
0.36.02026/10/2817 天前
0.35.32026/10/2818 天前
0.35.22026/10/2718 天前
0.35.12026/10/2619 天前
0.35.02026/10/2619 天前

关于 @fieldia/grid 的常见问题

@fieldia/grid 是什么?

Fieldia's table of lines on AG Grid: spreadsheet editing with Fieldia's own fields in the cells.

如何安装 @fieldia/grid?

在项目目录运行 npm install @fieldia/grid,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:ag-grid-community(^36.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@fieldia/grid 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@fieldia/grid 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@fieldia/grid 可以商用吗?

@fieldia/grid 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@fieldia/grid 的下载量有多少?

根据 npm 官方下载统计,@fieldia/grid 在 2026/10/15 – 2026/11/13 这 30 天内被下载 4,073 次,日均约 136 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@fieldia/grid 还在维护吗?

最新版本 0.36.1 发布于 2026/10/28(17 天前);至今共发布 48 个版本,其中过去 12 个月发布了 48 个;首次发布于 2026/10/02。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。