Grid to Form adapters

These adapters are used to adapt Grid Model interface to Form Model interface, so that you can pass a grid model instance into a form service and create or update grid records by means of a form controlled by that form service.

UIKernel.Adapters.Grid.toFormCreate

An adapter that converts the passed Grid Model into Form Model for creating new records of the grid on a separate form.

  const adaptedGridToFormModel = new UIKernel.Adapters.Grid.ToFormCreate(model, initialData);

Parameters:

Type Name Description
GridModel model Required. The instance of a Grid model
Object initialData Optional. Initial form data in the next format {‘field1’: ‘value1’, ‘field2’: ‘value2’, …}

Returns: new object with interface similar to Form Model.

async submit

  await adaptedGridToFormModel.submit(record);

Create a new record in the grid.

Parameters:

Type Name Description
Object record Required. Record to be created in the grid. It is expected to be in the next format {‘field1’: ‘value1’, ‘field2’: ‘value2’, …}

Check out Usage Example.


UIKernel.Adapters.Grid.toFormUpdate

An adapter that converts the passed Grid Model into Form Model for updating specified grid record on a separate form.

  const adaptedGridToFormModel = new UIKernel.Adapters.Grid.ToFormUpdate(model, id);

Parameters:

Type Name Description
GridModel model Required. The instance of a Grid model.
Any id Required. Id of the grid record to be updated.

Returns: new object with interface similar to Form Model.

async submit

  await adaptedGridToFormModel.submit(changes);

Apply form changes on the grid.

Parameters:

Type Name Description
Object changes Required. Changed grid record data to be applied on the grid. It is expected to be in the next format {‘field1’: ‘value1’, ‘field2’: ‘value2’, …}

Check out Usage Example.