Programming with DIALOG / DIALOG block structure |
The DISPLAY ARRAY sub-dialog is the controller to implement the navigation in a list of records, with option data modification actions.
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).
You typically bind a program array to a screen-array in order to display a page of records. However, the DIALOG instruction can also bind the program array to a simple flat screen-record. In this case, only one record will be visible at a time.
The next code example defines an array with a flat record and binds it to a screen array:
DEFINE p_items DYNAMIC ARRAY OF RECORD item_num INTEGER, item_name VARCHAR(50), item_price DECIMAL(6,2) END RECORD ... DIALOG 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:
DEFINE p_names DYNAMIC ARRAY OF VARCHAR(50) ... DIALOG DISPLAY ARRAY p_names TO sa.* BEFORE DELETE ... END DISPLAY ... END DIALOG
The name of the screen array specified with the TO clause identifies the list. The dialog class method such as 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.
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 instruction, 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.