The DISPLAY ARRAY sub-dialog

The DISPLAY ARRAY sub-dialog is the controller to implement the navigation in a list of records, with option data modification actions.

Program array to screen array binding

The DISPLAY ARRAY sub-dialog binds the members of the flat record (or the primitive member) of an array to the screen-array or screen-record fields specified with the TO keyword.

The number of variables in each record of the program array must be the same as the number of fields in each screen record (that is, in a single row of the screen array).

In most cases you want to bind a program array to a screen-array, in order to display a page of records. However, the DISPLAY ARRAY instruction can also bind the program array to a simple flat screen-record, to show one record at a time.

The next code example defines an array with a flat record and binds it to a screen array:

PUBLIC TYPE t_items DYNAMIC ARRAY OF RECORD
       item_num INTEGER,
       item_name VARCHAR(50),
       item_price DECIMAL(6,2)
   END RECORD
   ...
DIALOG items_list(p_items t_items)
   DISPLAY ARRAY p_items TO sa.*
      BEFORE ROW
      ...
   END DISPLAY
   ...
END DIALOG

If the screen array is defined with one field only, you can bind an array defined with a primitive type:

PUBLIC TYPE t_names DYNAMIC ARRAY OF VARCHAR(50)
   ...
DIALOG names_list(p_names t_names)
   DISPLAY ARRAY p_names TO sa.*
      BEFORE DELETE
      ...
   END DISPLAY
   ...
END DIALOG

Identifying a DISPLAY ARRAY sub-dialog

The name of the screen array specified with the TO clause identifies the list. The dialog class method takes the name of the screen array as the parameter, identifying the list. For example, you would use DIALOG.getCurrentRow("screen-array") to query for the current row in the list identified by 'screen-array'. The name of the screen-array is also used to qualify sub-dialog actions with a prefix.

Control blocks in DISPLAY ARRAY

Read-only record lists declared with the DISPLAY ARRAY sub-dialog can raise the following triggers:

In the singular DISPLAY ARRAYinstruction, BEFORE DISPLAY and AFTER DISPLAY blocks are typically used as initialization and finalization blocks. In a DISPLAY ARRAY sub-dialog of a DIALOG block, BEFORE DISPLAY and AFTER DISPLAY blocks will be executed each time the focus goes to (BEFORE) or leaves (AFTER) the group of fields defined by this sub-dialog.