netsuite-uif-spa-reference
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseNetSuite UIF Reference
NetSuite UIF 参考文档
Complete type definitions for and , the two packages that power NetSuite SPA (single-page application) user interfaces.
@uif-js/core@uif-js/component为支撑NetSuite SPA(单页应用)用户界面的两个包和提供完整的类型定义。
@uif-js/core@uif-js/componentWhen to Use
适用场景
- Building or modifying a UIF SPA component (JSX files)
- Looking up the exact API for a UIF class (Date, ArrayDataSource, Router, etc.)
- Checking available props/methods on UIF components (DataGrid, StackPanel, Button, etc.)
- Debugging runtime errors from UIF framework code
- Verifying enum values (for example, ,
Button.Hierarchy,GapSize)DataGrid.ColumnType - Understanding UIF Date vs. Native Date behavior
- 构建或修改UIF SPA组件(JSX文件)
- 查询UIF类(Date、ArrayDataSource、Router等)的精确API
- 查看UIF组件(DataGrid、StackPanel、Button等)的可用属性/方法
- 调试UIF框架代码引发的运行时错误
- 验证枚举值(例如、
Button.Hierarchy、GapSize)DataGrid.ColumnType - 了解UIF Date与原生Date的行为差异
Reference Data
参考数据
The type definitions are located in the subdirectory.
references/| File | Package | Contents |
|---|---|---|
| | Core framework: Date, ArrayDataSource, Ajax, Router, useState, useEffect, Context, etc. |
| | UI components: DataGrid, StackPanel, Button, Text, Badge, Heading, Card, ContentPanel, Modal, etc. |
类型定义位于子目录中。
references/| 文件 | 包 | 内容 |
|---|---|---|
| | 核心框架:Date、ArrayDataSource、Ajax、Router、useState、useEffect、Context等 |
| | UI组件:DataGrid、StackPanel、Button、Text、Badge、Heading、Card、ContentPanel、Modal等 |
Lookup Instructions
查询说明
To find information about a specific class or component:
-
Search by class name:
Search for `class Date` in the local `references/` directory. -
Search by method name:
Search for `lastOfMonth`, `firstOfMonth`, or `addDay` in `references/core.d.ts`. -
Search by enum:
Search for `enum GapSize`, `enum Hierarchy`, or `enum Type` in `references/component.d.ts`. -
Read a section: Once you find the line number, open that part of the file to view the full definition.
要查找特定类或组件的信息:
-
按类名搜索:
在本地`references/`目录中搜索`class Date`。 -
按方法名搜索:
在`references/core.d.ts`中搜索`lastOfMonth`、`firstOfMonth`或`addDay`。 -
按枚举搜索:
在`references/component.d.ts`中搜索`enum GapSize`、`enum Hierarchy`或`enum Type`。 -
查看章节:找到行号后,打开文件的对应部分查看完整定义。
Key Classes Quick Reference
关键类快速参考
@uif-js/core
@uif-js/core
| Class | Purpose | Key Members |
|---|---|---|
| UIF date wrapper | |
| Data provider for grids | |
| HTTP client | |
| SPA routing | |
| State hook | |
| Effect hook | |
| Context hook | |
| Context provider | |
| Context type string constants | |
| Memoized callback | |
| Memoized value | |
| Mutable ref container | |
| i18n support | |
| Redux-like state container | |
| Creates typed reducers | |
| Dispatch hook | |
| State selector hook | |
| Async operation cancellation | |
| Cancellation check | |
| Hierarchical grid/tree data | |
| On-demand data loading | |
| Immutable array helpers | |
| Immutable object helpers | |
| Locale-aware type formatting | |
| System icon constants (277) | |
| NetSuite record icons (43) | |
| Pub/sub event bus | |
| Keyboard key constants (101) | |
| 类 | 用途 | 关键成员 |
|---|---|---|
| UIF日期包装类 | |
| 表格数据提供器 | |
| HTTP客户端 | |
| SPA路由 | |
| 状态钩子 | |
| 副作用钩子 | |
| 上下文钩子 | |
| 上下文提供器 | |
| 上下文类型字符串常量 | |
| 记忆化回调 | |
| 记忆化值 | |
| 可变引用容器 | |
| 国际化支持 | |
| 类Redux状态容器 | |
| 创建类型化reducer | |
| 分发钩子 | |
| 状态选择器钩子 | |
| 异步操作取消 | |
| 取消状态检查 | |
| 层级表格/树数据 | |
| 按需数据加载 | |
| 不可变数组工具 | |
| 不可变对象工具 | |
| 区域感知类型格式化 | |
| 系统图标常量(277个) | |
| NetSuite记录图标(43个) | |
| 发布/订阅事件总线 | |
| 键盘按键常量(101个) | |
@uif-js/component
@uif-js/component
| Component | Purpose | Key Props |
|---|---|---|
| Table/grid display | |
| Layout container | |
| Clickable button | |
| Text display | |
| Status badges | |
| Section headings | |
| Card container | Content wrapper |
| Content wrapper | |
| Page header | |
| Dialog overlay | |
| Loading spinner | |
| CSS Grid layout | |
| Scrollable container | |
| Vertical nav | |
| Select input | |
| Text input | |
| Boolean input | |
| Tab navigation | |
| Hover tooltip | Via component |
| Dashboard card | |
| Loading placeholder | |
| Anchor element | |
| Image display | |
| Rich data list | |
| Date input | |
| Toggle switch | |
| Popup content | |
| Resizable sections | |
| Form field wrapper | |
| Grouped fields | |
| Multi-line text input | |
| Radio button group | |
| Inline alert/feedback | |
| Toast notification container | |
| Single toast message | |
| Collapsible sections | |
| Page navigation | |
| Action button container | |
| Dropdown menu | |
| Button with dropdown | |
| Filter container | |
| Single filter input | |
| Multi-value dropdown | |
| Multi-step wizard | |
| Navigation trail | |
| 组件 | 用途 | 关键属性 |
|---|---|---|
| 表格/网格展示 | |
| 布局容器 | |
| 可点击按钮 | |
| 文本展示 | |
| 状态徽章 | |
| 章节标题 | |
| 卡片容器 | 内容包装器 |
| 内容包装器 | |
| 页面头部 | |
| 对话框浮层 | |
| 加载动画 | |
| CSS Grid布局 | |
| 可滚动容器 | |
| 垂直导航 | |
| 选择输入框 | |
| 文本输入框 | |
| 布尔输入框 | |
| 标签页导航 | |
| 悬停提示 | 通过组件的 |
| 仪表盘卡片 | |
| 加载占位符 | |
| 锚点元素 | |
| 图片展示 | |
| 富数据列表 | |
| 日期输入框 | |
| 切换开关 | |
| 弹出内容 | |
| 可调整大小的区域 | |
| 表单字段包装器 | |
| 字段组 | |
| 多行文本输入框 | |
| 单选按钮组 | |
| 内联提示/反馈 | |
| 通知消息容器 | |
| 单个通知消息 | |
| 可折叠章节 | |
| 分页导航 | |
| 操作按钮容器 | |
| 下拉菜单 | |
| 带下拉菜单的按钮 | |
| 筛选器容器 | |
| 单个筛选器输入 | |
| 多选下拉框 | |
| 多步骤向导 | |
| 导航路径 | |
Global Component Enums
全局组件枚举
These enums are available directly from and are used across many components.
@uif-js/component这些枚举可直接从获取,并在多个组件中使用。
@uif-js/componentGapSize
GapSize
Used for , , on StackPanel, GridPanel, ContentPanel, AccordionPanel, etc.
itemGapouterGapcontentGapNONEXXXXSXXXSXXSXSSMLXLXXLXXXLXXXXLSPACING1XSPACING12XSMALLMEDIUMLARGEjsx
import { GapSize } from '@uif-js/component';
<StackPanel itemGap={GapSize.M} outerGap={GapSize.L} ... />Note: Some components (StackPanel, GridPanel) expose their own nested type. The top-level export from is the standard enum to use.
GapSizeGapSize@uif-js/component用于StackPanel、GridPanel、ContentPanel、AccordionPanel等的、、属性。
itemGapouterGapcontentGapNONEXXXXSXXXSXXSXSSMLXLXXLXXXLXXXXLSPACING1XSPACING12XSMALLMEDIUMLARGEjsx
import { GapSize } from '@uif-js/component';
<StackPanel itemGap={GapSize.M} outerGap={GapSize.L} ... />注意:部分组件(StackPanel、GridPanel)暴露自己的嵌套类型。从导出的顶层是标准枚举,建议使用该版本。
GapSize@uif-js/componentGapSizeInputSize
InputSize
Used for on , , , , , etc.
sizeTextBoxDropdownDatePickerTimePickerSwitchAUTOXXSXSSMLXLXXL用于、、、、等的属性。
TextBoxDropdownDatePickerTimePickerSwitchsizeAUTOXXSXSSMLXLXXLVisualizationColor
VisualizationColor
Semantic color set for , , , , color props:
KpiReminderBannerAvatarBadgeNEUTRALSUCCESSWARNINGDANGERINFOTEALORANGETURQUOISETAUPEGREENPINKBROWNLILACYELLOWPURPLEBLUEPINE用于、、、、颜色属性的语义化颜色集合:
KpiReminderBannerAvatarBadgeNEUTRALSUCCESSWARNINGDANGERINFOTEALORANGETURQUOISETAUPEGREENPINKBROWNLILACYELLOWPURPLEBLUEPINEKnown Pitfalls from Production Experience
生产经验中的常见陷阱
UIF Date
UIF Date
- returns a UIF Date object, not a number like native
Date.now().Date.now() - UIF Date uses ,
.year,.monthproperties (not.day,.getFullYear(),.getMonth())..getDate() - is 0-indexed (January = 0).
.month - UIF SPA runtime does not replace global ;
Datecreates a native JS Date.new Date() - Only returns UIF Date.
import { Date } from '@uif-js/core' - If the import fails silently, falls back to native
DateandDatereturns milliseconds.Date.now()
- 返回UIF Date对象,而非原生
Date.now()那样的数字。Date.now() - UIF Date使用、
.year、.month属性(不是.day、.getFullYear()、.getMonth())。.getDate() - 是0索引的(一月=0)。
.month - UIF SPA运行时不会替换全局;
Date创建的是原生JS Date。new Date() - 只有才会返回UIF Date。
import { Date } from '@uif-js/core' - 如果导入失败,会回退到原生
Date,此时Date返回毫秒数。Date.now()
StackPanel
StackPanel
- StackPanel rejects all null children; will throw an error.
{cond ? <Item>... : null} - Empty arrays are also rejected; inside StackPanel causes "Invalid StackPanel item" error. Never spread or inline an array that may be empty. Use a for-loop to append items:
{emptyArray}.for (var i = 0; i < items.length; i++) rootItems.push(items[i]); - Only safe pattern: Imperative array building: .
var items = []; if (x) items.push(<Item>...</Item>); - must have exactly one child.
StackPanel.Item
- StackPanel会拒绝所有null子项;会抛出错误。
{cond ? <Item>... : null} - 空数组也会被拒绝;在StackPanel中使用会导致"Invalid StackPanel item"错误。永远不要展开或内联可能为空的数组。使用for循环添加项:
{emptyArray}。for (var i = 0; i < items.length; i++) rootItems.push(items[i]); - 唯一安全的模式:命令式构建数组:。
var items = []; if (x) items.push(<Item>...</Item>); - 必须恰好有一个子项。
StackPanel.Item
Modal Placement
Modal 放置
- Modals must be at the root component level. Placing modals inside deeply nested containers (for example, GridPanel > ContentPanel > StackPanel) causes stacking context issues where the modal renders inline behind page content instead of as a floating overlay.
- Push modal elements into the root-level items array, not into a nested content array.
<StackPanel.Item> - Always use imperative array pattern for modals: build a array, then append to root items via for-loop.
modalItems
- Modal必须位于根组件层级。 将Modal放置在深层嵌套容器中(例如GridPanel > ContentPanel > StackPanel)会导致堆叠上下文问题,Modal会内联渲染在页面内容后方,而非作为浮层显示。
- 将Modal的元素添加到根层级的items数组中,而非嵌套的内容数组。
<StackPanel.Item> - 始终为Modal使用命令式数组模式:构建数组,然后通过for循环添加到根items中。
modalItems
Badge
Badge
- exists with values
Badge.SizeandDEFAULT; useSMALLfor compact badges.size={Badge.Size.SMALL} - prop uses
classListinternally; space-separated strings throwDOMTokenList.add().InvalidCharacterError - Always use a single class name per classList value.
- 存在枚举,值为
Badge.Size和DEFAULT;使用SMALL获取紧凑徽章。size={Badge.Size.SMALL} - 属性内部使用
classList;空格分隔的字符串会抛出DOMTokenList.add()。InvalidCharacterError - 始终为classList值使用单个类名。
DataGrid
DataGrid
- Full-width grids: distributes column space proportionally, but only within the grid's own computed width; it does not make the grid fill its container. To achieve full-width:
columnStretch={true}- Always keep explicit on every column; these act as proportional weights for
width. Without them, columns collapse to tiny minimums.columnStretch - Add on the DataGrid to make it fill its parent container's width.
rootStyle={{ width: '100%' }} - Give wider columns a larger value (for example, Description: 500, Name: 250, Badge: 70) so they get more proportional share.
width
- Always keep explicit
- is inherited from the base
rootStyleclass; all UIF components acceptComponentfor inline CSS on the root DOM element.rootStyle={{ ... }} - Do not use ; it is constructor-only and causes VDom "Writable property not found" errors on re-render.
stretchStrategy={{}} - TEMPLATED column callback:
contenthasargs, use{cell, context}orargs.cell.value.args.cell.row.dataItem - Always wrap TEMPLATED callbacks in try/catch; unhandled throws blank all remaining columns.
- is the correct prop for row height;
dataRowHeightis silently ignored.rowHeight - columns require grid-level
CHECK_BOX; settingeditable={true}on the column definition alone is not sufficient. Withouteditable: trueon the DataGrid itself, the column space renders but the checkbox widget is invisible.editable={true} - columns +
CHECK_BOXis unreliable;CELL_UPDATEmay not fire when checkboxes are toggled, making it impossible to track selection state. Preferred pattern: Use a TEMPLATED column with a toggle Button (for example,DataGrid.Event.CELL_UPDATE). Manage checked state in alabel={checked ? '\u2611' : '\u2610'}keyed by row ID. The ButtonuseRef({})flips the ref entry and calls aactioncounter to trigger re-render.setState - DataGrid.Options – key constructor-only vs writable props: The Options interface (constructor) accepts many properties that are NOT writable after construction:
- Constructor-only: ,
stretchStrategy,autoSize,bindingController,editingMode,preload,defaultColumnOptions,lockedLevels,beforeEditCell,stripedRows,multiColumnSortallowUnsort - Writable: ,
columnStretch,editable,paging,pageSize,pageNumber,sortable,placeholder,showHeaderhighlightRowsOnHover
- Constructor-only:
- – Similar to
maxViewportWidth, limits horizontal viewport. Use for grids with many columns to prevent horizontal overflow.maxViewportHeight - – Enables alternating row stripes for readability. Constructor option.
stripedRows={true} - –
editingMode(default) orDataGrid.EditingMode.CELL. ROW mode edits all cells in a row simultaneously.DataGrid.EditingMode.ROW - – Enables sorting by multiple columns. Off by default.
multiColumnSort={true} - – Lets users click a sorted column back to unsorted state.
allowUnsort={true} - Selection system – DataGrid has built-in selection via type and
SelectionColumn/DataGrid.SingleSelectionstrategies. More reliable than CHECK_BOX columns for row selection.DataGrid.MultiSelection - Useful imperative methods – ,
autoSize(),stretchColumns(),reload(),rowForDataItem(dataItem),scrollTo({cell/row/column}).pinRow(row, section)
- 全宽表格:会按比例分配列空间,但仅在表格自身计算的宽度内生效;它不会让表格填满容器。要实现全宽:
columnStretch={true}- 始终为每个列设置明确的;这些值在
width下作为比例权重。如果没有设置,列会收缩到极小的最小宽度。columnStretch - 在DataGrid上添加使其填满父容器宽度。
rootStyle={{ width: '100%' }} - 为较宽的列设置更大的值(例如Description:500,Name:250,Badge:70),使其获得更多比例空间。
width
- 始终为每个列设置明确的
- 继承自基础
rootStyle类;所有UIF组件都接受Component用于根DOM元素的内联CSS。rootStyle={{ ... }} - 不要使用;它仅在构造函数中可用,在重渲染时会导致VDom "Writable property not found"错误。
stretchStrategy={{}} - TEMPLATED列的回调:
content包含args,使用{cell, context}或args.cell.value。args.cell.row.dataItem - 始终将TEMPLATED回调包裹在try/catch中;未处理的异常会导致剩余所有列显示为空。
- 是设置行高的正确属性;
dataRowHeight会被静默忽略。rowHeight - 列需要表格级别的
CHECK_BOX;仅在列定义上设置editable={true}是不够的。如果DataGrid本身没有editable: true,列空间会渲染,但复选框小部件不可见。editable={true} - 列 +
CHECK_BOX不可靠;CELL_UPDATE在切换复选框时可能不会触发,导致无法跟踪选择状态。推荐模式:使用包含切换Button的TEMPLATED列(例如DataGrid.Event.CELL_UPDATE)。在label={checked ? '\u2611' : '\u2610'}中按行ID管理选中状态。Button的useRef({})切换ref中的值并调用action计数器触发重渲染。setState - DataGrid.Options – 区分构造函数专属属性与可写属性:Options接口(构造函数)接受许多在构造后不可写的属性:
- 仅构造函数可用:、
stretchStrategy、autoSize、bindingController、editingMode、preload、defaultColumnOptions、lockedLevels、beforeEditCell、stripedRows、multiColumnSortallowUnsort - 可写:、
columnStretch、editable、paging、pageSize、pageNumber、sortable、placeholder、showHeaderhighlightRowsOnHover
- 仅构造函数可用:
- – 与
maxViewportWidth类似,限制水平视口宽度。用于列数较多的表格以防止水平溢出。maxViewportHeight - – 启用交替行条纹以提高可读性。构造函数选项。
stripedRows={true} - –
editingMode(默认)或DataGrid.EditingMode.CELL。ROW模式允许同时编辑一行中的所有单元格。DataGrid.EditingMode.ROW - – 启用多列排序。默认关闭。
multiColumnSort={true} - – 允许用户点击已排序的列回到未排序状态。
allowUnsort={true} - 选择系统 – DataGrid通过类型和
SelectionColumn/DataGrid.SingleSelection策略提供内置选择功能。对于行选择,这比CHECK_BOX列更可靠。DataGrid.MultiSelection - 有用的命令式方法 – 、
autoSize()、stretchColumns()、reload()、rowForDataItem(dataItem)、scrollTo({cell/row/column})。pinRow(row, section)
Select / Dropdown
Select / Dropdown
- does not exist in
Select; importing it resolves to@uif-js/component. Usingundefinedin a TEMPLATED column silently throws, and try/catch fallbacks mask the error (renders em-dash or blank instead of a dropdown).<Select> - For dropdown components inside DataGrid: Use with these key options:
DataGrid.ColumnType.DROPDOWN- ; makes the dropdown always visible (not just on click).
inputMode: DataGrid.InputMode.EDIT_ONLY - ,
valueMember: 'value',displayMember: 'label'; binds to the value property, displays the label.bindToValue: true - : static
dataSource(cache viaArrayDataSourceto avoid recreation each render).useRef - ; for per-row dynamic options.
dataSourceConfigurator: function(row) { return new ArrayDataSource([...]); } - ; passed through to the underlying
widgetOptions: { allowEmpty: true, placeholder: 'Unassigned' }widget.Dropdown - Wire value changes via on the grid's
DataGrid.Event.CELL_UPDATEprop, not via onChange on individual cells.on - The grid itself must have for DROPDOWN columns to be interactive.
editable={true}
- For standalone dropdowns outside DataGrid: Use from
Dropdown(not@uif-js/component).Select
- 中不存在
@uif-js/component;导入它会得到Select。在TEMPLATED列中使用undefined会静默抛出异常,try/catch回退会掩盖错误(显示破折号或空白而非下拉框)。<Select> - DataGrid内的下拉组件:使用并设置以下关键选项:
DataGrid.ColumnType.DROPDOWN- ;使下拉框始终可见(不仅在点击时)。
inputMode: DataGrid.InputMode.EDIT_ONLY - 、
valueMember: 'value'、displayMember: 'label';绑定到value属性,显示label。bindToValue: true - : 静态
dataSource(通过ArrayDataSource缓存以避免每次渲染都重新创建)。useRef - ;用于每行动态选项。
dataSourceConfigurator: function(row) { return new ArrayDataSource([...]); } - ;传递给底层
widgetOptions: { allowEmpty: true, placeholder: '未分配' }小部件。Dropdown - 通过表格属性上的
on监听值变化,而非单个单元格的onChange。DataGrid.Event.CELL_UPDATE - 表格本身必须设置才能使DROPDOWN列可交互。
editable={true}
- DataGrid外的独立下拉框:使用中的
@uif-js/component(不要使用Dropdown)。Select
Modal
Modal
- enum only has:
Modal.Size,DEFAULT,SMALL,MEDIUM; there is noLARGE.EXTRA_LARGE - has an internal max-width that
Modal.Size.LARGEcannot override when both are set. TherootStyleprop's CSS takes precedence.size - For wider-than-LARGE modals: Remove the prop entirely and control width via
sizeonly:rootStylejsx<Modal rootStyle={{ width: '80vw', maxWidth: '1200px' }} ... /> - When a DataGrid is inside a Modal, always add on the DataGrid so it fills the modal's content area.
rootStyle={{ width: '100%' }} - is not a valid prop; using
onClosethrows "VDom: Writable property onClose not found" and prevents the modal from rendering. Modal/Window has noonClose={handler}callback prop. To handle close, useonCloseand provide your own ClosecloseButton={false}inside the modal content. For event-based close handling, use<Button>.on={{ [Window.Event.CLOSED]: handler }}
- 枚举只有:
Modal.Size、DEFAULT、SMALL、MEDIUM;没有LARGE。EXTRA_LARGE - 有内部最大宽度,当同时设置
Modal.Size.LARGE时无法覆盖;rootStyle属性的CSS优先级更高。size - 要比LARGE更宽的Modal:完全移除属性,仅通过
size控制宽度:rootStylejsx<Modal rootStyle={{ width: '80vw', maxWidth: '1200px' }} ... /> - 当DataGrid在Modal内部时,始终在DataGrid上添加使其填满Modal的内容区域。
rootStyle={{ width: '100%' }} - 不是有效属性;使用
onClose会抛出"VDom: Writable property onClose not found"并阻止Modal渲染。Modal/Window没有onClose={handler}回调属性。要处理关闭,使用onClose并在Modal内容中提供自定义的关闭closeButton={false}。要基于事件处理关闭,使用<Button>。on={{ [Window.Event.CLOSED]: handler }}
MenuButton
MenuButton
- extends
MenuButton; accepts all Button props (Button,label,icon,type, etc.) plushierarchy(array ofmenuorMenuItem.ItemDefinition).Menu.Options - Menu items are objects:
ActionItemDefinition. The{ label: 'Text', action: function() { ... } }property is what makes UIF treat them as clickable action items (vs submenu items which only haveaction/label).icon - Do not set on menu items; this can interfere with UIF's internal type discrimination between
icon: nullandActionItemDefinition, causing clicks to silently do nothing.SubmenuItemDefinition - Use for the standard three-dot menu icon:
SystemIcon.OVERFLOW.<MenuButton icon={SystemIcon.OVERFLOW} type={Button.Type.GHOST} menu={items} /> - Suppress tooltip with ; MenuButton inherits Button's tooltip behavior which can persist after the dropdown opens.
tooltip={null} - In TEMPLATED DataGrid columns use ref-based handlers in menu item actions to avoid stale closures: .
{ action: function() { myRef.current(item); } }
- 继承自
MenuButton;接受所有Button属性(Button、label、icon、type等)以及hierarchy(menu或MenuItem.ItemDefinition数组)。Menu.Options - 菜单项是对象:
ActionItemDefinition。{ label: '文本', action: function() { ... } }属性是UIF将其视为可点击操作项的标识(与仅包含action/label的子菜单项区分开)。icon - 不要在菜单项上设置;这会干扰UIF对
icon: null和ActionItemDefinition的内部类型判断,导致点击无响应。SubmenuItemDefinition - 使用作为标准三点菜单图标:
SystemIcon.OVERFLOW。<MenuButton icon={SystemIcon.OVERFLOW} type={Button.Type.GHOST} menu={items} /> - 使用禁用提示;MenuButton继承了Button的提示行为,下拉菜单打开后提示可能会持续显示。
tooltip={null} - 在DataGrid的TEMPLATED列中,菜单项的action使用基于ref的处理程序以避免闭包过时:。
{ action: function() { myRef.current(item); } }
General
通用注意事项
- is available on all UIF components (inherited from base
rootStyleclass). AcceptsComponentfor inline CSS on the root DOM element. Useful forRecord<string, string>,width,height,minWidth, etc.maxWidth - Never use empty as conditional fallback; use
<Text />(but not inside StackPanel!).null - Large datasets: Cap ArrayDataSource at ~500 rows for preview grids.
- 所有UIF组件都支持(继承自基础
rootStyle类)。接受Component用于根DOM元素的内联CSS。适用于设置Record<string, string>、width、height、minWidth等。maxWidth - 永远不要使用空的作为条件回退;使用
<Text />(但不要在StackPanel中使用!)。null - 大数据集:预览表格的ArrayDataSource限制在约500行。
Store / State Management
Store / 状态管理
- must wrap the component tree above any component calling
Store.ProvideroruseDispatch(); missing it throws an error from both hooks.useSelector() - takes an object mapping action type strings to handler functions. Each handler receives
Reducer.create()and must return a new state object (never mutate).(state, action) - Use inside reducers to return updated state without mutation.
ImmutableObject.set(state, 'key', value) - is constructor-only; create once at module level, not inside a component.
Store.create() - Access the existing store in deep child components via instead of prop-drilling.
useContext(ContextType.STORE)
- 必须包裹在任何调用
Store.Provider或useDispatch()的组件树上方;缺少它会导致两个钩子抛出错误。useSelector() - 接收一个将动作类型字符串映射到处理函数的对象。每个处理函数接收
Reducer.create()并必须返回新的状态对象(永远不要修改原状态)。(state, action) - 在reducers中使用返回更新后的状态,避免修改原状态。
ImmutableObject.set(state, 'key', value) - 仅在构造时可用;在模块级别创建一次,不要在组件内部创建。
Store.create() - 在深层子组件中通过访问现有Store,而非属性透传。
useContext(ContextType.STORE)
useEffect / Async Cleanup
useEffect / 异步清理
- Never update state after component unmount; always create a at the top of
CancellationTokenSource, declareuseEffect, pass token to async operations, callvar token = source.tokenin the cleanup function, and checksource.cancel()before calling any state setter.token.cancelled - Correct pattern:
javascript
useEffect(function() { var source = new CancellationTokenSource(); var token = source.token; Ajax.get({ url: '/api/data' }).then(function(result) { if (token.cancelled) return; setData(result.data); }); return function() { source.cancel(); }; }, []);
- 永远不要在组件卸载后更新状态;始终在顶部创建
useEffect,声明CancellationTokenSource,将token传递给异步操作,在清理函数中调用var token = source.token,并在调用任何状态设置器前检查source.cancel()。token.cancelled - 正确模式:
javascript
useEffect(function() { var source = new CancellationTokenSource(); var token = source.token; Ajax.get({ url: '/api/data' }).then(function(result) { if (token.cancelled) return; setData(result.data); }); return function() { source.cancel(); }; }, []);
DataGrid – TreeDataSource
DataGrid – TreeDataSource
- for hierarchy: Use
TreeDataSourceas thenew TreeDataSource({ data: items, childAccessor: (item) => item.children })prop. The first column must bedataSource(notDataGrid.ColumnType.TREE) to render the expand/collapse control.TEXT_BOXwith manual indent does not support expand/collapse.ArrayDataSource
- 层级数据使用:使用
TreeDataSource作为new TreeDataSource({ data: items, childAccessor: (item) => item.children })属性。第一列必须是dataSource(不是DataGrid.ColumnType.TREE)才能渲染展开/折叠控件。使用TEXT_BOX手动缩进不支持展开/折叠。ArrayDataSource
Form Building
表单构建
- Always wrap form controls in for consistent label spacing, accessibility, and mandatory indicators; bare
Field+ adjacentTextBoxlabel is not the correct pattern.Text - renders the control as read-only display text; use for detail/view screens without creating separate read-only components.
Field.Mode.VIEW - collapses a logical group of fields with a section title; preferred over bare
FieldGroupdividers for long forms.StackPanel - (not individual
RadioButtonGroupfor groups) manages selection state automatically.RadioButton - full enum:
Field.Size,AUTO,SMALL,MEDIUM,LARGE,XLARGE,XXLARGE.STRETCH
- 始终将表单控件包裹在中以获得一致的标签间距、可访问性和必填标识;裸
Field+ 相邻TextBox标签不是正确的模式。Text - 将控件渲染为只读展示文本;用于详情/查看页面,无需创建单独的只读组件。
Field.Mode.VIEW - 用章节标题折叠一组相关字段;对于长表单,优先于裸StackPanel分隔符使用。
FieldGroup - (而非单个
RadioButtonGroup)自动管理选择状态。RadioButton - 完整枚举:
Field.Size、AUTO、SMALL、MEDIUM、LARGE、XLARGE、XXLARGE。STRETCH
User Feedback (Banner / Growl)
用户反馈(Banner / Growl)
- must be in the component tree; it is not a service call. Add it once in the root shell, obtain a ref to it, then call
GrowlPanel(not.add(msg)) to push a.addMessage().GrowlMessage - Do not use for success/error feedback; use
Modalfor transient feedback andGrowlMessagefor persistent inline alerts.Banner - is always visible until dismissed;
Bannerauto-dismisses on a timer unlessGrowlMessageis set on the parentmanual={true}.GrowlPanel - values:
Banner.Color(informational),BLUE(emphasis),BLUE_DARK(success),GREEN(warning).ORANGE
- 必须在组件树中;它不是服务调用。在根外壳中添加一次,获取其ref,然后调用
GrowlPanel(不是.add(msg))添加.addMessage()。GrowlMessage - 不要使用进行成功/错误反馈;使用
Modal进行临时反馈,使用GrowlMessage进行持久内联提示。Banner - 始终可见直到被关闭;
Banner会在计时器到期后自动关闭,除非父GrowlMessage设置了GrowlPanel。manual={true} - 值:
Banner.Color(信息)、BLUE(强调)、BLUE_DARK(成功)、GREEN(警告)。ORANGE
FilterPanel
FilterPanel
- and
FilterPanel.filtersare deprecated; useFilterPanel.filtersVisibilityToggle+activeFiltersinstead.showClearAll - requires a
FilterChipprop (for example,picker,FilterChip.textBoxstatic pickers) to open the selection UI; without it the chip is display-only.FilterChip.date
- 和
FilterPanel.filters已废弃;使用FilterPanel.filtersVisibilityToggle+activeFilters替代。showClearAll - 需要
FilterChip属性(例如picker、FilterChip.textBox静态选择器)才能打开选择界面;没有该属性的话,芯片仅用于展示。FilterChip.date
Immutable State Updates
不可变状态更新
- Never mutate state directly; does not trigger re-render; use
state.items.push(x)and pass the result to the state setter.ImmutableArray.push(state.items, x) - is the correct pattern inside Store reducers; always return a new object, never
ImmutableObject.set(state, 'loading', true).Object.assign(state, ...)
- 永远不要直接修改状态;不会触发重渲染;使用
state.items.push(x)并将结果传递给状态设置器。ImmutableArray.push(state.items, x) - 在Store reducers中,是正确的模式;始终返回新对象,永远不要使用
ImmutableObject.set(state, 'loading', true)。Object.assign(state, ...)
Component API Quick Reference – DataGrid
组件API快速参考 – DataGrid
DataGrid Props
DataGrid 属性
| Prop | Type | Description |
|---|---|---|
| ArrayDataSource | Data provider |
| ColumnDefinition[] | Column definitions |
| Boolean | Stretch columns to fill width (writable) |
| Object | Inline CSS on root element |
| Number (px) | Row height ( |
| Boolean | Hover highlighting |
| Number (px) | Max height before internal scroll |
| Number (px) | Max width before horizontal scroll |
| Boolean | Enables cell editing (required for CHECK_BOX/DROPDOWN columns) |
| | Cell vs row editing mode (constructor-only) |
| Boolean | Alternating row stripes (constructor-only) |
| Boolean | Multi-column sort support (constructor-only) |
| Boolean | Allow unsort back to natural order (constructor-only) |
| | Virtualization preload strategy (constructor-only) |
| Boolean | Show/hide header row (writable) |
| String or Component | Empty grid placeholder (writable) |
| Boolean | Enable pagination (writable) |
| Number | Rows per page (writable) |
| Number | Current page (writable) |
| Boolean | Enable column sorting (writable) |
| SortCallback | Sort event handler |
| 属性 | 类型 | 描述 |
|---|---|---|
| ArrayDataSource | 数据提供器 |
| ColumnDefinition[] | 列定义 |
| Boolean | 拉伸列以填满宽度(可写) |
| Object | 根元素的内联CSS |
| Number(px) | 行高( |
| Boolean | 悬停高亮 |
| Number(px) | 内部滚动前的最大高度 |
| Number(px) | 水平滚动前的最大宽度 |
| Boolean | 启用单元格编辑(CHECK_BOX/DROPDOWN列必填) |
| | 单元格 vs 行编辑模式(仅构造函数可用) |
| Boolean | 交替行条纹(仅构造函数可用) |
| Boolean | 多列排序支持(仅构造函数可用) |
| Boolean | 允许恢复到自然排序(仅构造函数可用) |
| | 虚拟化预加载策略(仅构造函数可用) |
| Boolean | 显示/隐藏表头行(可写) |
| String 或 Component | 空表格占位符(可写) |
| Boolean | 启用分页(可写) |
| Number | 每页行数(可写) |
| Number | 当前页码(可写) |
| Boolean | 启用列排序(可写) |
| SortCallback | 排序事件处理函数 |
DataGrid Column Definition
DataGrid 列定义
| Property | Type | Description |
|---|---|---|
| String | Column ID |
| ColumnType enum | Column type (TEXT_BOX, TEMPLATED, DROPDOWN, etc.) |
| String | Data field binding |
| String | Header label |
| Number | Initial pixel width (also serves as proportional weight for stretch) |
| Number | Maximum pixel width (set to 9999 to allow stretch) |
| Number | Minimum pixel width |
| Boolean | Column-level editability |
| Boolean | Column-level sortability |
| Callback | TEMPLATED column render function: |
| Number | Relative stretch weight (alternative to width) |
| Boolean | Whether column participates in stretching |
| | Cell content alignment |
| | Cell vertical alignment |
| | When editable widgets are shown |
| Boolean | Mandatory field indicator |
| Callback | Per-cell customization function |
| VisibilityBreakpoint enum | Responsive column visibility |
| 属性 | 类型 | 描述 |
|---|---|---|
| String | 列ID |
| ColumnType枚举 | 列类型(TEXT_BOX、TEMPLATED、DROPDOWN等) |
| String | 数据字段绑定 |
| String | 表头标签 |
| Number | 初始像素宽度(也作为拉伸的比例权重) |
| Number | 最大像素宽度(设置为9999以允许拉伸) |
| Number | 最小像素宽度 |
| Boolean | 列级可编辑性 |
| Boolean | 列级可排序性 |
| Callback | TEMPLATED列的渲染函数: |
| Number | 相对拉伸权重(替代width) |
| Boolean | 列是否参与拉伸 |
| | 单元格内容对齐方式 |
| | 单元格垂直对齐方式 |
| | 可编辑小部件的显示时机 |
| Boolean | 必填字段标识 |
| Callback | 单元格自定义函数 |
| VisibilityBreakpoint枚举 | 响应式列可见性 |
DataGrid Enumerations
DataGrid 枚举
| Enum | Values | Access |
|---|---|---|
| | Column |
| | Column/grid |
| | Grid |
| | Column sort |
| | Grid |
| | Grid |
| | Grid visual style |
| | Row pinning target |
| | Column section |
| | Auto-size strategy |
| | Column alignment |
| | Column vertical alignment |
| | Responsive visibility |
| 枚举 | 值 | 访问方式 |
|---|---|---|
| | 列 |
| | 列/表格 |
| | 表格 |
| | 列排序 |
| | 表格 |
| | 表格 |
| | 表格视觉样式 |
| | 行固定目标区域 |
| | 列区域 |
| | 自动调整大小策略 |
| | 列对齐方式 |
| | 列垂直对齐方式 |
| | 响应式可见性 |
DataGrid Events
DataGrid 事件
| Event | Fires When | Access |
|---|---|---|
| Cell value changes | |
| Row added/removed/moved | Row lifecycle |
| Column changes | Column lifecycle |
| Row selection changes | Selection tracking |
| Cursor moves | Cursor tracking |
| Sort direction changes | Sort handling |
| Scroll state changed | Scroll tracking |
| Data binding complete (inherited) | Data lifecycle |
| 事件 | 触发时机 | 访问方式 |
|---|---|---|
| 单元格值变化 | |
| 行添加/删除/移动 | 行生命周期 |
| 列变化 | 列生命周期 |
| 行选择变化 | 选择跟踪 |
| 光标移动 | 光标跟踪 |
| 排序方向变化 | 排序处理 |
| 滚动状态变化 | 滚动跟踪 |
| 数据绑定完成(继承) | 数据生命周期 |