@agility-workbench/angular-grid

中文文档
1.15.0发布于 2026/11/02MITTypeScriptES Module构建来源已验证近 30 天下载 1730

Angular bindings for @agility-workbench/grid — a high-performance data grid. Supports Angular 20.3 through 22.

原始使用文档
文档目录5 节
  1. Installation
  2. Quick start
  3. Styling
  4. Angular components in the grid
  5. License

@agility-workbench/angular-grid

Angular bindings for @agility-workbench/grid — a high-performance data grid. Provides the standalone <awb-grid> component and re-exports the full core API, so you can import everything you need from one place. Supports Angular 20.3 through 22 (zone-based and zoneless applications) on Node 20.19+.

What each release added is on the documentation site's changelog.

Installation

npm install @agility-workbench/angular-grid

@agility-workbench/grid is installed automatically as a dependency; @angular/core (20.3–22, each major verified against the packed artifact) is a peer dependency your app provides.

Quick start

import { Component } from "@angular/core";
import {
  AwbGrid,
  ColumnType,
  type IGridAPI,
  type NgColDef,
} from "@agility-workbench/angular-grid";

@Component({
  selector: "app-example",
  standalone: true,
  imports: [AwbGrid],
  template: `
    <div style="height: 400px">
      <awb-grid
        [rowData]="rowData"
        [columnDefs]="columnDefs"
        rowIdKey="id"
        [rowNumbers]="true"
        (gridReady)="onGridReady($event)"
      />
    </div>
  `,
})
export class ExampleComponent {
  columnDefs: NgColDef[] = [
    { key: "name", label: "Name", type: ColumnType.STRING },
    { key: "price", label: "Price", type: ColumnType.NUMBER },
  ];

  rowData = [
    { id: "1", name: "Widget", price: 9.99 },
    { id: "2", name: "Gadget", price: 14.5 },
  ];

  onGridReady(api: IGridAPI): void {
    // Imperative API: sorting, selection, editing, exports, view state, …
  }
}

The grid fills its host element — give <awb-grid> (or a wrapper) a height. The component is also available via template reference: <awb-grid #grid="awbGrid" /> → grid.api.

[quickFilter] is a live input — the global search over every visible column. It filters rows by default, or behavior: "find" leaves every row in place and highlights matching cells instead, with a match counter, Enter / Shift+Enter stepping, and showBehaviorToggle to let the end user switch; the (quickFilterFindChanged) output reports the match count and the active match. See the core README for the match modes and what find can search.

Grid options are signal inputs, including pivot mode and sheets: [pivotMode] / [pivotColumns] are live (synced through the imperative API, so values assigned in gridReady are not overwritten), [pivotColumnMoveMode] is live, [pivotResultColumnDef] / [maxPivotColumns] / [pivotNoValuesMessage] / [pivotEmptyMessage] are creation-time, and [sheets] renders the footer tab strip with the same app-owned persistence contract as [savedViews]. See the core README for what pivot mode and sheets do.

Most inputs are live. The ones the grid reads only at creation (rowHeight, getRowId, rowIdKey, rowModelType, defaultColDef, groupColumnDef, pivotResultColumnDef, initialSort, … — the core's CREATION_ONLY_OPTION_KEYS, minus the bridged inputs) ignore later changes; in development mode (isDevMode()) the grid logs one console.warn naming the input when that happens. Re-create the <awb-grid> (for example under an @if, or a keyed @for) to apply such a change. The Angular page of the documentation site has the full live-vs-creation table.

Outputs: (gridReady), (cellClicked), (rowClicked), (cellDoubleClicked), (rowDoubleClicked), (cellValueChanged), (selectionChanged), (sortChanged), (filterChanged), (quickFilterFindChanged), (historyChanged), (columnsChanged), (paginationChanged) and (gridError) (the core error event — not (error), which Angular would also bind as a native DOM listener on the host). (columnsChanged) and (sortChanged) carry source: "user" | "api"; persist column state on "user" so restoring it never echoes back. Anything else: api.on(eventName, handler).

Styling

Nothing to do — the grid delivers its own stylesheet when it attaches, once per document, and once per shadow root for grids inside one.

Under a strict Content Security Policy without style-src 'unsafe-inline', pass a nonce via the styleNonce input (page-global, so use the same value for every grid). To load the stylesheet yourself instead — via angular.json styles or a global import of @agility-workbench/grid/styles.css — set suppressStyleInjection on each grid, so the two copies do not fight in the cascade.

Angular components in the grid

Column definitions accept Angular component classes wherever the core accepts a class component — cellRenderer, cellEditor, tooltipComponent, headerTooltip, actionFrameComponent, the set-filter components in filterParams, and the header components headerComponent (header content) and headerCellComponent (the whole header cell; contract IHeaderNgComp). The same slots are adapted in [defaultColDef], [groupColumnDef], and [pivotResultColumnDef]. A component receives its params either through an input named params or by implementing awbInit(params) (plus optional awbRefresh(params)):

import { Component, input } from "@angular/core";
import type { CellRendererParams } from "@agility-workbench/angular-grid";

@Component({
  standalone: true,
  template: `<strong>{{ params()?.value }}</strong>`,
})
export class BoldCell {
  readonly params = input<CellRendererParams>();
}

const columnDefs: NgColDef[] = [{ key: "name", label: "Name", cellRenderer: BoldCell }];

Cell editors implement ICellEditorNgComp (getValue() plus optional focus, isParsed, isCancelBeforeStart). Menu items returned from getColumnMenuItems / bodyContextMenu / multiColumnMenu may use TemplateRefs for their left/right slots (NgMenuItem).

License

MIT

版本与发布记录

@agility-workbench/angular-grid 共发布 17 个版本,首次发布于 2026/08/24;过去 12 个月发布了 17 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
1.15.0latest2026/11/027 天前
1.13.02026/10/1723 天前
1.12.02026/10/1724 天前
1.11.02026/10/1624 天前
1.10.12026/10/1525 天前
1.10.02026/10/1426 天前

关于 @agility-workbench/angular-grid 的常见问题

@agility-workbench/angular-grid 是什么?

Angular bindings for @agility-workbench/grid — a high-performance data grid. Supports Angular 20.3 through 22.

如何安装 @agility-workbench/angular-grid?

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

@agility-workbench/angular-grid 支持 TypeScript 吗?

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

@agility-workbench/angular-grid 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@agility-workbench/angular-grid 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^20.19.0 || ^22.12.0 || >=24.0.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@agility-workbench/angular-grid 可以商用吗?

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

@agility-workbench/angular-grid 的下载量有多少?

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

@agility-workbench/angular-grid 还在维护吗?

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