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.t()

#ctx.view

The currently active view controller (dialog, drawer, popover, embed, etc.); used to access view-level info and actions. Provided by FlowViewContext; only available inside content opened via ctx.viewer or ctx.openView.

#Use Cases

ScenarioDescription
Dialog/drawer contentIn content, use ctx.view.close() to close, or render Header, Footer for title and actions
After form submitCall ctx.view.close(result) to close and pass result back
JSBlock / ActionCheck ctx.view.type for view type, or read ctx.view.inputArgs for open params
Association select, sub-tableRead inputArgs for collectionName, filterByTk, parentId, etc. for loading data

Note: ctx.view is only available in RunJS when a view context exists (e.g. inside ctx.viewer.dialog() content, dialog form, association selector); in a normal page or backend context it is undefined—use optional chaining: ctx.view?.close?.().

#Type

type FlowView = {
  type: 'drawer' | 'popover' | 'dialog' | 'embed';
  inputArgs: Record<string, any>;
  Header: React.FC<{ title?: React.ReactNode; extra?: React.ReactNode }> | null;
  Footer: React.FC<{ children?: React.ReactNode }> | null;
  close: (result?: any, force?: boolean) => void;
  update: (newConfig: any) => void;
  navigation?: ViewNavigation;
  destroy?: () => void;
  submit?: () => Promise<any>;
};

#Common properties and methods

Property/MethodTypeDescription
type'drawer' | 'popover' | 'dialog' | 'embed'Current view type
inputArgsRecord<string, any>Params passed when opening the view
HeaderReact.FC | nullHeader component for title and actions
FooterReact.FC | nullFooter for buttons, etc.
close(result?, force?)voidClose current view; optional result passed back to caller
update(newConfig)voidUpdate view config (e.g. width, title)
navigationViewNavigation | undefinedIn-view navigation (tabs, etc.)

Currently only dialog and drawer support Header and Footer.

#inputArgs (common fields)

Fields in inputArgs depend on how the view was opened; common ones:

FieldDescription
viewUidView UID
collectionNameCollection name
filterByTkPrimary key filter (single record)
parentIdParent id (associations)
sourceIdSource record id
parentItemParent item data
sceneScene (e.g. create, edit, select)
onChangeCallback after select/change
tabUidCurrent tab UID (in-page)

Access via ctx.getVar('ctx.view.inputArgs.xxx') or ctx.view.inputArgs.xxx.

#Examples

#Close current view

await ctx.resource.runAction('create', { data: formData });
ctx.view?.close();

ctx.view?.close({ id: newRecord.id, name: newRecord.name });

#Header / Footer in content

function DialogContent() {
  const ctx = useFlowViewContext();
  const { Header, Footer, close } = ctx.view;
  return (
    <div>
      <Header title="Edit" extra={<Button size="small">Help</Button>} />
      <div>Form content...</div>
      <Footer>
        <Button onClick={() => close()}>Cancel</Button>
        <Button type="primary" onClick={handleSubmit}>OK</Button>
      </Footer>
    </div>
  );
}

#Branch by view type or inputArgs

if (ctx.view?.type === 'embed') {
  ctx.model.setProps('headerStyle', { display: 'none' });
}

const collectionName = ctx.view?.inputArgs?.collectionName;
if (collectionName === 'users') {
  // User selector
}

#Relation to ctx.viewer, ctx.openView

UseRecommended
Open new viewctx.viewer.dialog() / ctx.viewer.drawer() or ctx.openView()
Operate current viewctx.view.close(), ctx.view.update()
Open paramsctx.view.inputArgs

ctx.viewer opens views; ctx.view is the current view instance; ctx.openView opens configured flow views.

#Notes

  • ctx.view is only available inside a view; on a normal page it is undefined.
  • Use optional chaining: ctx.view?.close?.() to avoid errors when no view context.
  • close(result) passes result to the Promise returned by ctx.viewer.open().

#Related

  • ctx.openView(): open configured flow view
  • ctx.modal: lightweight modals (info, confirm, etc.)

ctx.viewer provides dialog(), drawer(), popover(), embed(); inside their content you can use ctx.view.