Skip to Content
JoyUI

数据网格

可配置 columns / data 的电子表格:编辑、筛选、导出。

续约表、库存表等场景共用同一 DataGrid:传入 data、columns、getRowId、onDataChange 即可,不要复制演示行数据。

Renewals

Total Results24 rows

Use arrow keys to navigate, Shift and arrows to select cells, and Enter or F2 to edit. Copy and paste cells with your keyboard. Column headings sort; column separators resize with arrow keys.

Northwind Freight
Owen Park
Latin America
Closed won
40
$9,600
49%
Lumen Freight
Tyler Hayes
Europe
Closed won
105
$37,800
90%
Cedar Freight
Tyler Hayes
Latin America
Proposal
230
$96,600
64%
Brightline Freight
Marcus Johnson
Asia Pacific
Proposal
115
$41,400
78%
Harbor Freight
Daniel Kim
Latin America
Committed
10
$4,200
72%
Pinecrest Freight
Marcus Johnson
Europe
Closed won
470
$169,200
72%
Atlas Freight
Sarah Bennett
Latin America
Discovery
45
$16,200
95%
Summit Freight
Owen Park
Asia Pacific
Negotiation
255
$107,100
93%
Fieldstone Freight
Marcus Johnson
Europe
Discovery
660
$237,600
82%
Evergreen Freight
Marcus Johnson
Latin America
Negotiation
46
$13,800
56%
Meridian Freight
Owen Park
Asia Pacific
Discovery
119
$42,840
73%
Redwood Freight
Daniel Kim
Europe
Committed
192
$80,640
90%
Westbridge Freight
Tyler Hayes
North America
Proposal
265
$63,600
41%
Sterling Freight
Sarah Bennett
Latin America
Closed won
338
$101,400
58%
Juniper Freight
Marcus Johnson
Asia Pacific
Negotiation
411
$147,960
75%
Oakmont Freight
Owen Park
Europe
Discovery
484
$203,280
92%
Sum6.4K
Sum$2.2M
Avg72.3%
A1Count 1

安装

npx @joyui/cli add data-grid --yes

或通过 JoyUI MCP / CLI 安装。

应用场景

销售续约工作台:列定义来自 CRM 字段,行数据来自 API;编辑后经 onDataChange 写回。

<DataGrid
  aria-label="Renewals"
  data={rows}
  columns={columns}
  getRowId={(row) => row.id}
  onDataChange={setRows}
  height={520}
  exportFileName="renewals.csv"
/>

API

DataGrid
参数说明类型可选值默认值
data行数据。T[]——
columns列定义。DataGridColumn<T>[]——
getRowId行键。(row) => string——
onDataChange编辑回写。(next) => void——
height可视高度。number——
className合并到根节点的额外类名。string——
DataGridColumn
字段说明类型必填示例
key字段。string是"account"
header表头。string是"Account"
width列宽。number否180
type编辑类型。"text"|"number"|"select"否"select"
optionsselect 选项。string[]否["EU"]