User interface programming / Table views |
Controlling row creation and deletion in an editable record list.
The INPUT ARRAY instruction handles record list edition. This controller allows the user to directly edit existing rows and to create or remove rows with implicit actions.
The following implicit actions are created by default by the INPUT ARRAY dialog:
... INPUT ARRAY p_items FROM sa.* -- Allow only row append and delete implicit actions. ATTRIBUTES(AUTO APPEND=FALSE, INSERT ROW=FALSE) ... END INPUT ...
Specific control blocks are available to take control when a row is created or deleted:
Dynamic arrays and the ui.Dialog class provide methods such as array.deleteElement() or ui.Dialog.appendRow() to modify the list. When using these methods, the predefined triggers such as BEFORE DELETE or BEFORE INSERT are not executed. While it is safe to use these methods within a DISPLAY ARRAY, you must take care when using an INPUT ARRAY. For example, you should not call such methods in triggers like BEFORE ROW, AFTER INSERT, BEFORE DELETE.
Users can append temporary rows by moving to the end of the list, or when executing the append action. Appending temporary rows is a different from inserting a row; an appended row is considered temporary until the user modifies a field while an inserted row remains in the list even if the user does not modify a field.
By default, when the last row is removed by a delete action, the INPUT ARRAY instruction will automatically create a new temporary row at the same position. The visual effect of this behavior can be misinterpreted - if no data was entered in the last row, you can't see any difference. However, the last row is really deleted and a new row is created, and the BEFORE DELETE / AFTER DELETE / AFTER ROW / BEFORE ROW / BEFORE INSERT control block sequence is executed. In order to deny to avoid the creation of a new temporary row when the last row is deleted, set AUTO APPEND = FALSE attribute.
The insert, append or delete actions will be automatically disabled according to the context: If the INPUT ARRAY is using a static array that becomes full, or if the MAXCOUNT attribute is reached, both insert and append actions will be disabled. The delete action is automatically disabled when AUTO APPEND = FALSE and there are no more rows in the array.