Using DetailForms from MetaGrids

Using DetailForms from MetaGrids

A DetailForm is a MetaForm that can be used by a MetaGrid to add, update or copy a record.

 

The MetaForm to be used as DetailForm

This can be any MetaForm (or an object type inheriting MetaForm). A minimal example needs:

  • A DefaultToolbar with, at least, Save and Cancel buttons.

  • Another instance of the MetaDataSource used by the MetaGrid.

  • A MetaViewer in which to add or update a record of the MetaGrid that launches the DetailForm.

  • Links to make it work:

    • A TableIO link from the toolbar to the viewer.

    • A Data link from the MetaDataSource to the MetaViewer.

    • A FormActionTarget from an empty source (defaults to <Container>) to the MetaViewer.

Additional object instances can be added as needed.

The MetaDataSource does not execute a FetchData call when the form is opened, it instead gets the instance from the calling form passed to it. This means data links or events (including SSEH) may not be triggered. If there are other MetaDataSources on the DetailForm that have a Data link with the passed-in MetaDataSource as source, they too need to be mapped.

The MetaGrid using the DetailForm

There are several attributes controlling the MetaGrid behavior relating to DetailForms. To use a DetailForm it is required to assign a DetailForm and have at least one entry in DetailFormForUpdates. Some other attributes control how and when the DetailForm will be opened.

The DetailForm attribute

This attribute is required to use a DetailForm. It holds the name of the MetaForm repository object that should be opened as DetailForm (i.e. the form described in the previous chapter).

The DetailFormDataSources attribute

At least one MetaDataSource is required here (i.e. the one used as source in the MetaGrids Data link). The attribute is a comma separated list, so additionally required MetaDataSources can also be added here. The MetaDataSources are mapped to the DetailForm, meaning the instances are passed to it.

 

If the instances have the same name in both forms, an entry here is just that name. If there are different names for the DataSource in the calling form and the DetailForm, the entry is <instance name on the DetailForm>=<instance name on the parent form> .

The DetailFormForUpdates attribute

If this is set to true, the DetailForm is used for Add, Copy and Update operations.

The DetailFormModal attribute

If this is true, the DetailForm is opened as a modal form. Otherwise it is non-modal. In the web a modal form is shown as a popup form, a non-modal form as a new form with breadcrumbs for navigation.

The DefaultActionBehavior attribute

The DefaultAction is a combined event of double-click and enter (the enter key is currently not supported for the web). If its behavior is set to Update, the DetailForm is opened in an updatable state when double-clicking a row in the grid.

Example

In this example, there are two mapped DataSources. One with a different names in parent form and DetailForm, the other with the same name.

The parent Form has a toolbar, a grid and two datasources.

image-20251209-093512.png

With these links:

image-20251209-093549.png

As you can see, the CustomerDataSource does not provide its data to any target in the parent form here. It is only required because the DetailForm has a viewer and its instance of the DataSource does not FetchData due to being mapped.

 

On the Grid we need to set the attributes like this to tell it which DetailForm to open, how and when to open it and how to map the DataSources.

image-20251209-093917.png

In DetailForm we need the name of the DetailForm repository object. In the DetailFormDataSources we need to list the DataSources to map. The OrderCustomerDataSource instance in the DetailForm is called ExternalOrderCustomerDataSource which is why we need to map the names like this. The CustomerDataSource instances are named the same on both Forms which is why the simple name is enough. By checking DetailFormForUpdates, the DetailForm is used when the Grid would be set to update mode by the toolbar and since the DetailForm is quite large, DetailFormModal os set to false so it opens as a full form.

 

The DetailForm has these instances:

image-20251209-095554.png

With these links:

image-20251209-094515.png

The FormActionTarget link is used by DetailForms to determine which of its instances to apply the FormAction (Add, Update, Copy) to. Its source is the form itself, the target is the instance.

 

Also note that the Data link between the two datasources is not required here. This is because the DataSources are mapped and won’t trigger events or fetch data when the DetailForm is opened.

 

Aside from that the DetailForm is a regular Form.

 

When the parent Form is launched, we only see its toolbar and grid.

image-20251209-095116.png

Clicking Add, Copy or Update on the toolbar will then open the DetailForm and enable the OrderViewer.

image-20251209-095833.png

And the Customer data shown in the CustomerViewer.

image-20251209-095922.png

Since we defined in the grid that the DetailForm is non-modal, we can use the breadcrumbs (Home / Orders / Order) to navigate back to the parent form. If the DetailForm were opened modal, we could just close it to go back.