docs/docs/en/runjs/context/get-value.md
In JSField, JSItem, and other editable field contexts, returns the current value of the field. Use with ctx.setValue(v) for two-way binding with the form.
| Scenario | Description |
|---|---|
| JSField | Read user input or current form value in editable custom fields |
| JSItem | Read current cell value in table/sub-table editable items |
| JSColumn | Read row field value when rendering a column |
Note:
ctx.getValue()is only available in RunJS contexts with form binding; it does not exist in event flow, linkage, etc., where there is no field binding.
getValue<T = any>(): T | undefined;
undefined if the field is not registered or not filled.ctx.getValue() resolves in this order:
If the form is not yet rendered or the field is not registered, the result may be undefined.
const current = ctx.getValue();
if (current == null || current === '') {
ctx.render(<span>Please enter something</span>);
} else {
ctx.render(<span>Current: {current}</span>);
}
const { Input } = ctx.libs.antd;
const defaultValue = ctx.getValue() ?? '';
ctx.render(
<Input
defaultValue={defaultValue}
onChange={(e) => ctx.setValue(e.target.value)}
/>
);
js-field:value-change: container event when value changes from outside; use to update display