logologo
Get Started
Guide
Development
Plugins
API
Home
English
简体中文
日本語
한국어
Español
Português
Deutsch
Français
Русский
Italiano
Türkçe
Українська
Tiếng Việt
Bahasa Indonesia
ไทย
Polski
Nederlands
Čeština
العربية
עברית
हिन्दी
Svenska
Get Started
Guide
Development
Plugins
API
Home
logologo
RunJS Overview
Import Modules
Render in Container

Globals

window
document
navigator

ctx

ctx.blockModel
ctx.collection
ctx.collectionField
ctx.dataSource
ctx.dataSourceManager
ctx.element
ctx.exit()
ctx.exitAll()
ctx.filterManager
ctx.form
ctx.getModel()
ctx.getValue()
ctx.getVar()
ctx.i18n
ctx.importAsync()
ctx.initResource()
ctx.libs
ctx.location
ctx.logger
ctx.makeResource()
ctx.message
ctx.modal
ctx.model
ctx.notification
ctx.off()
ctx.on()
ctx.openView()
ctx.render()
ctx.request()
ctx.requireAsync()
ctx.resource
ctx.route
ctx.router
ctx.setValue()
ctx.sql
ctx.t()
ctx.view
Previous Pagenavigator
Next Pagectx.collection

#ctx.blockModel

The parent block model (BlockModel instance) of the current JS field / JS block.

In form blocks, table blocks, and similar scenarios, ctx.blockModel points to the block model that hosts the current JS logic. It can be used to:

  • Access the collection bound to the block (collection)
  • Access the block resource (resource) for refresh, selected rows, etc.
  • Access the form instance inside the block (form) for reading/validating form values
  • Listen to block events (e.g. formValuesChange) for linkage or re-render

#Type definition (simplified)

blockModel: BlockModel | FormBlockModel | TableBlockModel | CollectionBlockModel | DataBlockModel | null;

The concrete type depends on the block type (e.g. form blocks usually use FormBlockModel, table blocks use TableBlockModel).

#Common properties and methods

ctx.blockModel.collection; // collection bound to the block
ctx.blockModel.resource;   // resource used by the block (SingleRecordResource / MultiRecordResource, etc.)
ctx.blockModel.form;       // form block: Antd Form instance, supports getFieldsValue/validateFields, etc.

// Listen to events (e.g. render summary based on form changes)
ctx.blockModel.on?.('formValuesChange', (values) => {
  // handle latest form values
});

// Re-render the current block (some block models implement rerender)
ctx.blockModel.rerender?.();

Tips:

  • For form-related scenarios, ctx.blockModel.form.getFieldsValue() returns all form values
  • For table-related scenarios, ctx.blockModel.resource.getSelectedRows() returns selected rows
  • Different BlockModel subclasses may expose expand/collapse/refresh methods; use them as supported