跳到主要内容

RelationEditor

Defined in: packages/rxdb-model/src/entity-table/editors/relation-editor.ts:17

关系字段搜索下拉编辑器(oneToOne / manyToOne)

  • 顶部搜索框:实时过滤可选实体列表
  • 键盘导航:↑ ↓ 移动焦点,Enter / 点击确认,Escape 取消
  • 空值支持:nullable=true 时列表首项为"(空)"
  • 存储外键 ID,显示关联实体的 displayName

Implements​

  • IEditor<string>

Constructors​

Constructor​

new RelationEditor(items?, nullable?): RelationEditor;

Defined in: packages/rxdb-model/src/entity-table/editors/relation-editor.ts:44

创建关系下拉编辑器

Parameters​

ParameterTypeDefault valueDescription
items| RelatedEntityItem[] | (() => RelatedEntityItem[])[]候选实体列表,或每次打开时重新求值的工厂函数
nullablebooleanfalse是否允许空值,为 true 时列表首项为“(空)”

Returns​

RelationEditor

Properties​

editorType​

readonly editorType: "relation-editor" = 'relation-editor';

Defined in: packages/rxdb-model/src/entity-table/editors/relation-editor.ts:36

VTable 编辑器类型标识(注册到 VTable 的编辑器名)

Methods​

adjustPosition()​

adjustPosition(rect): void;

Defined in: packages/rxdb-model/src/entity-table/editors/relation-editor.ts:198

按新的单元格矩形重新定位浮层

Parameters​

ParameterType
rectRectProps

Returns​

void

Implementation of​

IEditor.adjustPosition

getValue()​

getValue(): string;

Defined in: packages/rxdb-model/src/entity-table/editors/relation-editor.ts:188

返回当前选中的关联实体 ID(未选中为空字符串)

Returns​

string

Implementation of​

IEditor.getValue

isEditorElement()​

isEditorElement(target): boolean;

Defined in: packages/rxdb-model/src/entity-table/editors/relation-editor.ts:193

判断目标元素是否位于本编辑器浮层内

Parameters​

ParameterType
targetHTMLElement

Returns​

boolean

Implementation of​

IEditor.isEditorElement

onEnd()​

onEnd(): void;

Defined in: packages/rxdb-model/src/entity-table/editors/relation-editor.ts:176

移除浮层并解绑全局事件

Returns​

void

Implementation of​

IEditor.onEnd

onStart()​

onStart(ctx): void;

Defined in: packages/rxdb-model/src/entity-table/editors/relation-editor.ts:93

弹出搜索浮层,解析候选列表并绑定键盘与点击事件

Parameters​

ParameterType
ctxEditContext<string>

Returns​

void

Implementation of​

IEditor.onStart