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

Global Variables

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 Pagectx.makeResource()
Next Pagectx.modal

#ctx.message

Ant Design global message API; shows short messages at the top center. Messages auto-close after a while or can be closed by the user.

#Use Cases

ScenarioDescription
JSBlock / JSField / JSItem / JSColumnQuick feedback: validation, copy success, etc.
Form actions / event flowSubmit success, save failed, validation failed
JSActionClick or batch action feedback

#Type

message: MessageInstance;

MessageInstance is the Ant Design message API.

#Common Methods

MethodDescription
success(content, duration?)Success message
error(content, duration?)Error message
warning(content, duration?)Warning message
info(content, duration?)Info message
loading(content, duration?)Loading (usually closed manually)
open(config)Open with custom config
destroy()Close all messages

Parameters:

  • content: string or ConfigOptions
  • duration: optional seconds; default 3; 0 = no auto-close

ConfigOptions (when content is an object):

interface ConfigOptions {
  content: React.ReactNode;
  duration?: number;
  onClose?: () => void;
  icon?: React.ReactNode;
}

#Examples

#Basic

ctx.message.success('Done');
ctx.message.error('Failed');
ctx.message.warning('Please select data first');
ctx.message.info('Processing...');

#With ctx.t (i18n)

ctx.message.success(ctx.t('Copied'));
ctx.message.warning(ctx.t('Please select at least one row'));
ctx.message.success(ctx.t('Exported {{count}} records', { count: rows.length }));

#Loading and manual close

const hide = ctx.message.loading(ctx.t('Saving...'));
await saveData();
hide();
ctx.message.success(ctx.t('Saved'));

#open with config

ctx.message.open({
  type: 'success',
  content: 'Custom success',
  duration: 5,
  onClose: () => console.log('closed'),
});

#Close all

ctx.message.destroy();

#ctx.message vs ctx.notification

ctx.messagectx.notification
PositionTop centerTop right
UseShort, auto-dismissPanel with title/description; can stay longer
TypicalAction feedback, validation, copyTask done, system notice, longer content

#Related

  • ctx.notification: top-right notifications
  • ctx.modal: modal confirm
  • ctx.t(): i18n; often used with message