Skip to main content

Editing Lifecycle

Editing in FD Components is dataset-owned. Grid editors, standalone data-aware editors, and direct application code all participate in the same edit lifecycle.

Edit an existing record​

dataSet.edit();
dataSet['company'] = 'Northstar Systems';
dataSet['active'] = true;
dataSet.post();

The lifecycle is:

browse → edit → browse

edit() starts an edit buffer for the current record. Writes go through that buffer. post() validates and commits the local edit to dataset change tracking.

Cancel an edit​

dataSet.edit();
dataSet['company'] = 'Temporary value';
dataSet.cancel();

cancel() discards the active edit buffer and returns to browse state.

Append a new record​

dataSet.append();
dataSet['company'] = 'BluePeak Logistics';
dataSet['credit_limit'] = 42000;
dataSet.post();

append() creates a new record at the logical end of the current view.

Field defaults, calculated-field initialization, and onNewRecord initialization run as part of new-record setup.

Insert a record​

dataSet.insert();
dataSet['company'] = 'Vertex Manufacturing';
dataSet.post();

insert() creates a new record according to dataset insertion semantics, while append() explicitly targets the logical end of the view.

For many CRUD forms, append() expresses intent more clearly when the user chooses “New”.

Delete the current record​

dataSet.delete();

Delete behavior participates in the dataset update mode and adapter persistence model. In cached-update workflows, a deletion remains part of the pending change set until updates are applied or cancelled.

Validation happens inside the lifecycle​

Field and record validation are part of posting. Do not bypass the dataset by mutating internal record storage.

dataSet.edit();
dataSet['company'] = '';
dataSet.post(); // required-field validation can reject the post

Bound editors use the same validation model.

Lifecycle hooks​

FdcDataSet provides hooks around the major operations:

  • beforeEdit / afterEdit;
  • beforeInsert / afterInsert;
  • beforePost / afterPost;
  • beforeDelete / afterDelete;
  • beforeCancel / afterCancel.

Use hooks for business workflow behavior tied to the operation boundary. Keep field-level validation in field validators and cross-field business validation in the record validator.

Initialize new records​

Use defaults for schema-level defaults and onNewRecord for application initialization that needs dataset context.

Schema default:

FdcBooleanField(
name: 'active',
defaultValue: true,
)

Dataset-level initialization can then fill values that depend on application context or another field.

Post is not always the remote commit boundary​

post() commits the active edit buffer to dataset record state. Persistence depends on FdcUpdateMode:

  • immediate — adapter-backed posted changes are scheduled for application immediately;
  • cachedUpdates — changes accumulate until applyUpdates() is called.

That distinction is covered in Change Tracking.

Next: Change Tracking