Grid: Add row(s)

See also: Grid: Fill, Grid: Clear, Grid: Remove row, Grid: Replace selected rows

Actions – Abstract

The action Grid: Zeile hinzufügen adds one or more rows from a Data grid linked as a Target element or one of the other List elements if the service configuration of the target element allows this

The action Grid: Zeile hinzufügen adds one or more rows from a Data grid linked as a Target element or one of the other List elements if the service configuration of the target element allows this.

images/download/attachments/189434207/image-2024-10-14_9-29-31-version-1-modificationdate-1728890971213-api-v2.png

►IMPORTANT◄ The specification of a target element from the group of List elements is required so that this action can be selected under Action type.

The rows to be added to the Target element must exist as input data ($input) for the action.

  • The Update if contained is set by default. This setting checks whether the corresponding data item is already contained in the Target element for each row to be added. If this is the case, the relevant entry in the Target element is updated with data from the $input. However, an object with identical content (for example, a copy of the original) is not considered a match.

  • If the Update if contained option is not set, the rows to be added are always added to the Target element as a copy.

Example

In connection with a truck transport, information on the vehicle type of the tractor truck is to be entered via the portal. The standard tractor trucks available in the company's own fleet are stored as options in a Combobox element (with the 'Options' display type). If necessary, it should also be possible to add data for non-standard tractor trucks 'spontaneously' – i.e. without creating additional master data. These should appear as an additional option in the Combobox element for the respective transport. If the relevant option is selected, the stored detailed data should be displayed again so that corrections can be made if necessary.

Runtime example:

  • Initially, the form offers three standard tractor truck types to choose from:

    images/download/attachments/189434207/image2020-7-8_13-43-9-version-1-modificationdate-1728888254718-api-v2.png



  • Clicking on the Additional type? Button displays a Column layout for entering details for an additional tractor truck type:

    images/download/attachments/189434207/image2020-7-8_13-46-16-version-1-modificationdate-1728888254724-api-v2.png



  • If the Column layout Non-standard-tractor contains valid data (here: all required fields are filled in), a click on the Submit Button adds the corresponding entry as an additional option for Tractor truck (type), then selects it and hides the Column layout Non-standard-tractor again:

    images/download/attachments/189434207/image2020-7-8_13-47-37-version-1-modificationdate-1728888254727-api-v2.png

The data structure of a tractor type in the Combobox element with the truck data field becomes clear with this addition in the structure export for the portal:

{
"truck": {
"type": "FERRARI FYT",
"hp": 220,
"registration": "Y-123456"
}
}

The detailed data fields for 'Type' (type) and 'Power (HP)' (hp) are also used in the default entries that were entered in the example as 'Static values" in the service configuration for the Combobox element.

The required information 'registration number' (registration) is only used for non-standard tractor truck types, so that a value for this characteristic identifies the entry as 'non-standard type'. In the 'Label expression' within the service configuration, an attached asterisk appears, as shown in the screenshot (*).

Configuration:

images/download/attachments/189434207/image-2024-10-14_9-37-18-version-1-modificationdate-1728891438327-api-v2.png

For the Additional type? Button, next to the Tractor truck (type) Combobox, the behaviour shown on the left is configured to display and initialise the Column layout with the 'Non-standard-tractor' details:

  • The behaviour reacts to the Triggering event Click which provides the default value $true as $input. This is exceptionally important because this behaviour can also be called by a Execute behaviour action, which then provides the currently selected tractor truck type as $input.


  • The Behaviour type Calculate was chosen to determine by means of a Check expression whether the value $true is available as $input or not. The Actions on 'true' are only executed if this is the case, i.e. if the 'Additional type?' Button was pressed. The Actions on 'false' are executed if the behaviour was called because a 'Non-standard-tractor Type' was interactively selected for the tractor in the Combobox 'Tractor truck (type)', the data of which should then appear in the details area.


  • Under the Actions on 'true', the action Populate empty element data is executed with the Column layout 'Non-standard-tractor' as the Target element, so that this is initialized with an empty data item and can be used to maintain data for a new type. Subsequently, the same Target element is made visible via Show element and the Additional type? Button is set to invisible via Hide element.


  • The Actions on 'false' follow the same pattern, except that in the first step the Column layout is not initialized with empty element data. Instead, the input data ($input) is set to the Column layout using Populate element data, i.e. the data of the tractor truck type selected by the Combobox when the behaviour is called (not in the screenshot). This data can then be updated as required by pressing the 'Submit' Button (see below).

images/download/attachments/189434207/image-2024-10-15_8-7-7-version-1-modificationdate-1728972427228-api-v2.png

For the 'Submit' Button in the Column layout for the definition of a 'Non-standard-tractor' the behaviour shown on the left is configured:

  • The behaviour reacts to the Triggering event Click.


  • The Behaviour type Validate element checks the Column layout linked as the Target element 'Non-standard-tractor'. Only if all contained elements are filled in a valid way, the Actions on 'true' are executed with the validated data. If entries are missing or invalid, a click on 'Submit' – as long as no Actions on 'false' are defined – is ineffective.


  • Under the Actions on 'true', the action Grid: Zeile hinzufügen is executed with the Combobox 'Tractor truck (type)' as the Target element. The Update if contained option is set so that corrections (see above) can be made to an already inserted entry without creating a duplicate.


  • After adding the new option, it will be assigned as a selection by Set value with the same Target element. The Value refers to the $input that contains the added data item.


  • The action Hide element (collapsed in the screenshot) with the Column layout 'Non-standard-tractor' as the Target element hides the details area again.


  • The action Show element (collapsed in the screenshot) refers to the Additional type? Button as the Target element, which is hidden when the details area is displayed and should become visible again after 'Submitting' the details.