Overview
Callbacks + Events
Application hooks, lifecycle callbacks, and custom events between components.
Table Metadata (Lifecycle Callback)
Description: these metadata orchestrate the main hooks of the route's data lifecycle.
md_before_save: callback executed before sync (insert/update/delete), useful for validations and payload transformations.md_after_save: post-sync callback, useful for UI notifications, dependent refresh, side effects.- In batch save (grid with
md_batch_save, spreadsheet)md_before_saveandmd_after_saverun once per record, with that record (record.<field>.value/.next()), as in the single save; the changes made bymd_before_saveare saved. Ifmd_before_savestops a record (falseor an error), no record of the batch is saved. - In batch save
md_after_savereceivesevent = { batch: true, index, count }(recordindexofcount;nullin the single save) and runs with the batch changes already marked as saved: adataSource.fetchData()in the hook does not ask to confirm pending changes. To reload the data only once, on the last record:if (!event?.batch || event.index === event.count - 1) { await dataSource.fetchData(); }. - Compatibility: up to version 1.7.27 batch save called
md_before_saveandmd_after_saveonly once, with the array of records. A hook written for the array must be rewritten for the single record. md_after_load: callback after data loading, useful for runtime initializations and record post-processing.md_conditional_update_rule: conditional rule that enables/blocks update on the current record.md_conditional_delete_rule: conditional rule that enables/blocks delete on the current record.
Snippet (table example):
md_after_load = "utility.onAfterLoad"md_before_save = "utility.beforeSaveGuard"md_after_save = "utility.afterSaveNotify"md_conditional_update_rule = "record.status !== 'LOCKED'"md_conditional_delete_rule = "record.canDelete === true"
Column Metadata (Field-Level Events)
Description: these metadata manage reactive behavior and point validation on individual fields.
mc_selection_changing_custom_function: hook before value change (pre-change).mc_selection_changed_custom_function: hook after value change (post-change).mc_default_value_callback: dynamic default value calculation.mc_suggest_value_callback: callback for value suggestion/auto-population.mc_validation_custom_callback: custom business validation on the field.mc_logic_converter_read_callback: value conversion on read (rendering/model mapping).mc_logic_converter_write_callback: value conversion on write (before save).mc_value_change_trigger_event: UI event that triggers value change (keyup,change, etc.).
Snippet (column example):
mc_default_value_callback = "utility.defaultProvince"mc_selection_changing_custom_function = "utility.beforeProvinceChange"mc_selection_changed_custom_function = "utility.afterProvinceChange"mc_validation_custom_callback = "utility.validateProvince"mc_value_change_trigger_event = "change"
Typical Event Flow
1. Record loading: md_after_load.
2. User interactions on fields: mc_selection_changing_custom_function -> mc_selection_changed_custom_function.
3. Save: md_before_save.
4. Persistence completed: md_after_save.
Operational Notes
- Keep callbacks idempotent and with explicit error handling.
- Avoid heavy logic in high-frequency field callbacks (
keyup). - Use table callbacks for general orchestration and column callbacks for point logic.
Result:
- predictable behavior between load/edit/save;
- clear separation between global rules (table) and local rules (column).
Screenshot
