ctx.blockModel
The parent block model (BlockModel instance) where the current JS Field / JS Block is located. In scenarios such as JSField, JSItem, and JSColumn, ctx.blockModel points to the form block or table block carrying the current JS logic. In a standalone JSBlock, it may be null or the same as ctx.model.
Scenarios
Note:
ctx.blockModelis only available in RunJS contexts where a parent block exists. In standalone JSBlocks (without a parent form/table), it may benull. It is recommended to perform a null check before use.
Type Definition
The specific type depends on the parent block type: form blocks are mostly FormBlockModel or EditFormModel, while table blocks are mostly TableBlockModel.
Common Properties
Relationship with ctx.model and ctx.form
In a JSField, ctx.model is the field model, and ctx.blockModel is the form or table block carrying that field; ctx.form is typically ctx.blockModel.form.
Examples
Table: Get selected rows and process
Form Scenario: Validate and Refresh
Listen for Form Changes
Trigger Block Re-render
Notes
- In a standalone JSBlock (without a parent form or table block),
ctx.blockModelmay benull. It is recommended to use optional chaining when accessing its properties:ctx.blockModel?.resource?.refresh?.(). - In JSField / JSItem / JSColumn,
ctx.blockModelrefers to the form or table block carrying the current field. In a JSBlock, it may be itself or an upper-level block, depending on the actual hierarchy. resourceonly exists in data blocks;formonly exists in form blocks. Table blocks typically do not have aform.
Related
- ctx.model: The model of the current execution context.
- ctx.form: Form instance, commonly used in form blocks.
- ctx.resource: Resource instance (equivalent to
ctx.blockModel?.resource, use directly if available). - ctx.getModel(): Get other block models by UID.

